参考谷歌发布的新TextInputLayout
,如何更改浮动标签文本颜色?
在样式中设置colorControlNormal
、colorControlActivated
、colorControlHighLight
无济于事。
这就是我现在所拥有的:
发布于 2015-06-01 11:34:13
<style name="TextAppearance.App.TextInputLayout" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/red</item>
<item name="android:textSize">14sp</item>
</style>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@color/gray" //support 23.0.0
app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout" >
<android.support.v7.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint" />
</android.support.design.widget.TextInputLayout>
发布于 2015-05-30 23:30:04
找到答案了,使用android.support.design:hintTextAppearance
属性来设置您自己的浮动标签外观。
示例:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:hintTextAppearance="@style/TextAppearance.AppCompat">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"/>
</android.support.design.widget.TextInputLayout>
发布于 2017-09-01 02:59:11
您不需要使用android:theme="@style/TextInputLayoutTheme"
来更改浮动标签的颜色,因为它会影响用作标签的小TextView的整个主题。相反,您可以在以下情况下使用app:hintTextAppearance="@style/TextInputLayout.HintText"
:
<style name="TextInputLayout.HintText">
<item name="android:textColor">?attr/colorPrimary</item>
<item name="android:textSize">@dimen/text_tiny_size</item>
...
</style>
如果解决方案有效,请让我知道:-)
https://stackoverflow.com/questions/30546430
复制相似问题