android - 仅更改 TextInputLayout 提示文本样式

标签 android styles hint textstyle

我正在尝试将 TextInputLayout 提示文本样式更改为粗体。我使用 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>

我试着设置

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

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

但它不起作用。提示文本始终具有编辑文本的样式(如果编辑文本是粗体,则自动具有粗体提示,否则提示是正常的):

enter image description here

最佳答案

想到的最简单的事情是:

内部 strings.xml <string name="myHint"><b>Your hint here</b></string>
在你的layout.xml文件中<EditText android:hint="@string/myHint"/>

关于android - 仅更改 TextInputLayout 提示文本样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40218714/

相关文章:

java - 常用输入输出语句

c# - WPF DataGrid 为带有 * 的 ColumnWidth 应用样式不起作用

android - EditText 提示随重力消失

android - 在 Android 中通过蓝牙接收 xml 字符串时出错

android - 带有 fragment 或 Activity 的抽屉导航?

android - 带有 Rails 的 Twilio 中的 OTP 验证未知关键字错误

java - 如何在代码中设置提示文本?

xaml - 是否可以为一个元素设置两个样式模板并决定在代码隐藏中使用哪一个?

WPF 在自定义控件中保留基本样式

Delphi:菜单提示错误