首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何更改TextInputLayout的浮动标签颜色

如何更改TextInputLayout的浮动标签颜色
EN

Stack Overflow用户
提问于 2015-05-30 20:52:36
回答 21查看 221.5K关注 0票数 226

参考谷歌发布的新TextInputLayout,如何更改浮动标签文本颜色?

在样式中设置colorControlNormalcolorControlActivatedcolorControlHighLight无济于事。

这就是我现在所拥有的:

EN

回答 21

Stack Overflow用户

发布于 2015-06-01 11:34:13

代码语言:javascript
复制
<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>
票数 108
EN

Stack Overflow用户

发布于 2015-05-30 23:30:04

找到答案了,使用android.support.design:hintTextAppearance属性来设置您自己的浮动标签外观。

示例:

代码语言:javascript
复制
<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>
票数 70
EN

Stack Overflow用户

发布于 2017-09-01 02:59:11

您不需要使用android:theme="@style/TextInputLayoutTheme"来更改浮动标签的颜色,因为它会影响用作标签的小TextView的整个主题。相反,您可以在以下情况下使用app:hintTextAppearance="@style/TextInputLayout.HintText"

代码语言:javascript
复制
<style name="TextInputLayout.HintText">
  <item name="android:textColor">?attr/colorPrimary</item>
  <item name="android:textSize">@dimen/text_tiny_size</item>
  ...
</style>

如果解决方案有效,请让我知道:-)

票数 24
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30546430

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档