无法在TextInputLayout中更改提示的颜色

时间:2015-10-22 23:40:45

标签: android android-layout android-styles android-textinputlayout

我想将TextInputLayout中可见的提示颜色设置为我的自定义颜色(蓝色)。不幸的是,到目前为止我所取得的成就是: screen 1

enter image description here

如何使用自定义颜色设置提示样式?

这就是我到目前为止所做的:

styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/police_blue</item>
        <item name="colorPrimaryDark">@color/police_blue_dark</item>
        <item name="colorAccent">@color/police_blue_light</item>

        <item name="android:textColorHint">@color/police_blue_light</item>
        <item name="colorControlNormal">@color/police_blue_light</item>
        <item name="colorControlActivated">@color/police_blue_light</item>
        <item name="colorControlHighlight">@color/police_blue_light</item>
    </style>

layout_file.xml

<android.support.design.widget.TextInputLayout
        android:id="@+id/login_username_wrapper"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/login_username"
            android:hint="@string/username_hint"
        />
    </android.support.design.widget.TextInputLayout>

1 个答案:

答案 0 :(得分:0)

应用 android:background =“@ drawable / edittext_bg” 在你的布局上

    <EditText
        android:la`enter code here`yout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/login_username"
        android:hint="@string/username_hint"
    />

在drawable之后创建文件 edittext_bg.xml 并将此代码放入其中。

<layer-list>
   <item>
    <shape android:shape="rectangle">
        <!-- Draw a 2dp width border around shape -->
        <stroke`android:color="#ff1e0c"`
           android:width="2dp"
            />
    </shape>
</item>
<!-- Overlap the left, top and right border using background color  -->
<item android:bottom="2dp">
    <shape android:shape="rectangle">
        <solid android:color="#fffbce"/>
    </shape>
</item>

希望它对你有所帮助。