参考谷歌发布的新TextInputLayout,如何更改浮动标签文本颜色?
在样式中设置colorControlNormal, colorControlActivated, colorControlHighLight没有帮助。
这是我现在拥有的:
参考谷歌发布的新TextInputLayout,如何更改浮动标签文本颜色?
在样式中设置colorControlNormal, colorControlActivated, colorControlHighLight没有帮助。
这是我现在拥有的:
当前回答
更改提示颜色和编辑文本下划线颜色: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>
其他回答
在最新版本的支持库(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>
你应该换一下颜色
<style name="Base.Theme.DesignDemo" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#673AB7</item>
<item name="colorPrimaryDark">#512DA8</item>
<item name="colorAccent">#FF4081</item>
<item name="android:windowBackground">@color/window_background</item>
</style>
而不是Brahmam Yamani的答案,我更喜欢使用Widget.Design.TextInputLayout作为父。这确保了所有必需的项都存在,即使不是所有项都被覆盖。在Yamanis的答案中,如果调用setErrorEnabled(true),应用程序将崩溃与一个无法解析的资源。
简单地更改样式如下:
<style name="TextLabel" parent="Widget.Design.TextInputLayout">
<!-- Hint color and label color in FALSE state -->
<item name="android:textColorHint">@color/Color Name</item>
<item name="android:textSize">20sp</item>
<!-- Label color in TRUE state and bar color FALSE and TRUE State -->
<item name="colorAccent">@color/Color Name</item>
<item name="colorControlNormal">@color/Color Name</item>
<item name="colorControlActivated">@color/Color Name</item>
</style>
你不需要使用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>
让我知道解决方案是否有效:-)