参考谷歌发布的新TextInputLayout,如何更改浮动标签文本颜色?
在样式中设置colorControlNormal, colorControlActivated, colorControlHighLight没有帮助。
这是我现在拥有的:
参考谷歌发布的新TextInputLayout,如何更改浮动标签文本颜色?
在样式中设置colorControlNormal, colorControlActivated, colorControlHighLight没有帮助。
这是我现在拥有的:
当前回答
在我的情况下,我添加了这个“app:hintTextAppearance=“@color/colorPrimaryDark”在我的TextInputLayout小部件。
其他回答
我建议你为TextInputLayout做风格主题,只改变强调色。设置父主题为你的应用程序基础主题:
<style name="MyTextInputLayout" parent="MyAppThemeBase">
<item name="colorAccent">@color/colorPrimary</item>
</style>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:theme="@style/MyTextInputLayout">
在最新版本的支持库(23.0.0+)中,TextInputLayout采用以下XML属性来编辑浮动标签颜色:
我尝试使用android:textColorHint在android.support.design.widget. textinputlayout它工作得很好。
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@color/colorAccent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hello"
android:imeActionLabel="Hello"
android:imeOptions="actionUnspecified"
android:maxLines="1"
android:singleLine="true"/>
</android.support.design.widget.TextInputLayout>
有太多复杂的解决方案。下面是一个改变浮动标签颜色的程序。
<com.google.android.material.textfield.TextInputLayout
app:hintTextColor="@color/white"/>
除了更改其他属性:
更改框描边颜色:
<com.google.android.material.textfield.TextInputLayout
app:boxStrokeColor="@color/green"
更改方框描边宽度:
<com.google.android.material.textfield.TextInputLayout
app:boxStrokeWidth="1.5dp"
更改编辑TextInputEditText提示颜色:
<com.google.android.material.textfield.TextInputEditText
android:textColorHint="@color/white"
更改TextInputEditText的颜色:
<com.google.android.material.textfield.TextInputEditText
android:textColor="@color/white" />
更改提示颜色和编辑文本下划线颜色:colorControlActivated
更改字符计数器颜色:textColorSecondary
更改错误信息的颜色:colorControlNormal
要更改密码可见性按钮颜色:colorForeground
更多关于TextInputLayout的信息请阅读http://www.zoftino.com/android-textinputlayout-tutorial
<style name="MyAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorControlActivated">#e91e63</item>
<item name="android:colorForeground">#33691e</item>
<item name="colorControlNormal">#f57f17</item>
<item name="android:textColorSecondary">#673ab7</item>
</style>