【问题标题】:Android: how to see all TextAppearance stylesAndroid:如何查看所有 TextAppearance 样式
【发布时间】:2018-04-14 12:22:21
【问题描述】:

我正在尝试设置我的登录表单的样式,但是我无法将输入的背景设置为白色。

@android:style/TextAppearance.DeviceDefault.Inverse 有效,因为它为输入标题显示白色;但是,对于提示文本,它仍然是黑色的。

有没有办法让我一次看到各种文本外观样式,而不是逐个尝试每种样式?我注意到有很长的已定义样式列表,但我无法将它们全部查看以进行比较。

<android.support.design.widget.TextInputLayout
                 android:id="@+id/textinputlayout"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_marginLeft="15dp"
                 android:layout_marginRight="15dp"
                 android:layout_marginTop="40dp"
                 app:hintTextAppearance="@android:style/TextAppearance.DeviceDefault.Inverse">

                 <android.support.design.widget.TextInputEditText
                     android:id="@+id/nameEdit"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:hint="User Name" />

</android.support.design.widget.TextInputLayout>

【问题讨论】:

    标签: android text styles appearance


    【解决方案1】:

    尝试在TextInputEditText中添加这个

    android:textColorHint="@color/yourColor"

    【讨论】:

    • 感谢您的回复,但有什么方法(例如规格表)可以查看样式是如何定义的?我不仅想更改提示文本颜色,还想比较哪种定义的样式更好看。
    【解决方案2】:

    你可以这样做。

    更改TextInputLayoutLEFT-TOP 文字颜色

    app:hintTextAppearance="@style/text_in_layout_hint_Style"
    

    样式代码

    <style name="text_in_layout_hint_Style">
        <item name="android:textColor">#FF0000</item>
    </style>
    

    您可以在.java 中执行此操作。

    textInputLayout.setHintTextAppearance(R.style.text_in_layout_hint_Style);
    

    【讨论】:

    • 感谢您的回复,但是有什么方法(例如规格表)可以查看样式是如何定义的?我不仅想更改提示文本颜色,还想比较哪种定义的样式更好看。
    • 您可以使用更多TextInputLayout 并在您的xml 代码中尝试不同的样式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-16
    • 2016-07-19
    • 1970-01-01
    • 1970-01-01
    • 2022-06-14
    • 1970-01-01
    相关资源
    最近更新 更多