![](/img/trans.png)
[英]Cannot find the setter for attribute 'android:layout_width' with parameter type int on android.widget.ImageView
[英]Cannot find the setter for attribute 'android:textColorHint' with parameter type int
我正在嘗試使用數據綁定在<android.support.design.widget.TextInputLayout>
視圖上設置textColorHint
,如下所示
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="@dimen/text_input_layout_height"
android:layout_marginBottom="@dimen/text_input_margin_bottom"
android:hint="@{FieldHandlers.hasValidSpaces(account.firstName)? @string/first_name : @string/invalid_firstname}"
app:textColorHint="@{FieldHandlers.hasValidSpaces(account.firstName)? @android:color/holo_red_light : @android:color/holo_red_light}"/>
但是,它給出以下錯誤信息:
Error:(70, 38) Cannot find the setter for attribute 'app:textColorHint' with parameter type int on android.support.design.widget.TextInputLayout.
有沒有一種方法可以對此屬性使用數據綁定? 如果我直接輸入顏色文字或@color/myColor
引用, @color/myColor
。
不知道您是否仍然需要此答案。 但是該attr不起作用,因為它在TextInputLayout.class
沒有提供設置器。 而且那就是sdk類-您不允許更改它。 問題在於解析TintTypedArray
在構造函數內部:
if (a.hasValue(R.styleable.TextInputLayout_android_textColorHint)) {
mDefaultTextColor = mFocusedTextColor =
a.getColorStateList(R.styleable.TextInputLayout_android_textColorHint);
}
您可以嘗試使用TextInputLayout.setHintTextAppearance()在綁定內有效。
警告:但請注意,支持庫版本28中引入了一些行為更改。
看起來錯誤文本顏色和提示文本顏色現在在錯誤狀態下始終相同(如果您將調用TextInputLayout.setError()
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.