简体   繁体   中英

Change TextInputLayout only hint text style

I am trying to change TextInputLayout hint text style to bold. I changed color and other styles of hint in styles with use of TextAppearance :

 <style name="MyTextInputLayoutTheme" parent="@android:style/TextAppearance">
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_width">match_parent</item>
        <item name="android:textColorHint">@color/black_50</item>
        <item name="colorControlNormal">@color/green</item>
        <item name="hintAnimationEnabled">false</item>        
    </style>

I tried to set

<item name="android:textStyle">normal</item>

or

<item name="android:textStyle">bold</item>

but it doesn't work. Hint text always has style of edit text (if edittext is bold, it automatically has bold hint, if not, the hint is normal) :

在此输入图像描述

The easiest thing that comes to mind is this:

Inside strings.xml <string name="myHint"><b>Your hint here</b></string>
In your layout.xml file <EditText android:hint="@string/myHint"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM