更改 TextInputLayout 计数器的颜色

时间:2021-04-25 10:42:30

标签: android material-design material-components-android android-textinputlayout android-textinputedittext

我正在尝试更改 TextInputLayout 计数器的颜色

我已经尝试了接受的答案,但它们不起作用。

https://stackoverflow.com/a/33880925/11110509

<com.google.android.material.textfield.TextInputLayout
        android:id="@+id/til_custom_msg"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:hint="Message"
        app:counterEnabled="true"
        app:counterMaxLength="300"
    
        //Accepted answer one
        app:counterTextAppearance="@android:color/white">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/et_custom_msg"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/colorWhite" />

    </com.google.android.material.textfield.TextInputLayout>

接受的答案二:

https://stackoverflow.com/a/41257235/11110509

<style name="CounterStyle" parent="TextAppearance.AppCompat.Small">
    <item name="android:textColor">@android:color/white</item>
    <!--other parameters that you want to change -->
</style>

app:counterTextAppearance="@style/CounterStyle"

问题可能是因为我的 TextInputLayout 使用的是材质版本

<com.google.android.material.textfield.TextInputLayout

他们的使用支持

<android.support.design.widget.TextInputLayout

如果是这样,我该如何使用 Material one?

1 个答案:

答案 0 :(得分:1)

简单使用

'app:counterTextColor="YOUR_PREFERRED_COLOR"'

资源:CounterTextColor

相关问题