【问题标题】:Change color of "hint"改变“提示”的颜色
【发布时间】:2020-10-28 06:06:35
【问题描述】:

如何更改代码中“提示”的颜色?

因为背景很暗,我看不到文字和需要写的地方... 非常感谢您的帮助!

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="Veuillez taper son prénom ici"
    android:textSize="15dp"
    android:layout_gravity="center" />

&lt;LinearLayout&gt; android:background="@color/colorBlack"/&gt;

【问题讨论】:

  • 添加以下 android:textColorHint="" 在封闭的 qoutes 中定义您的提示文本颜色

标签: android colors hint


【解决方案1】:

在您的 XML 代码中,您可以添加 android:textColorHint

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="Veuillez taper son prénom ici"
    android:textSize="15dp"
    android:textColorHint="#ff0000"
    android:layout_gravity="center" />

或者您可以通过编程方式更改提示颜色:

edittext.setHintTextColor(Color.RED);

【讨论】:

    【解决方案2】:

    将 id 添加到 EditText 以识别标签。 .xml 文件

    <EditText
        android:id="@+id/ET_hint"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="Veuillez taper son prénom ici"
        android:textSize="15dp"
        android:layout_gravity="center" />
    

    .java 文件

    EditText et_hint = findViewById(R.id.ET_hint);
    et_hint.setHintTextColor(getResources().getColor(R.color.white));
    

    【讨论】:

      【解决方案3】:

      在您的 xml 中使用 android:textColorHint="#ff0000"edittext.setHintTextColor(Color.BLUE); 在您的 Java 程序中以语法方式设置提示颜色。

      【讨论】:

        猜你喜欢
        • 2017-12-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-26
        相关资源
        最近更新 更多