Hello, can you tell me how can I tint the text hin...
# android
m
Hello, can you tell me how can I tint the text hint of my TextInputLayout from theme colors? I was doing tests by I have not found any way.
Copy code
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
    <item name="colorPrimary">#2f2f2f</item>
    <item name="colorPrimaryDark">#2f2f2f</item>
    <item name="colorPrimaryVariant">#007038</item>
    <item name="colorOnPrimary">#0D1DB1</item>
    <item name="colorSecondary">#456321</item>
    <item name="colorSecondaryVariant">#965874</item>
    <item name="colorOnSecondary">#741080</item>
    <item name="colorError">#F44336</item>
    <item name="colorOnError">#810000</item>
    <item name="colorSurface">#DFDFDF</item>
    <item name="colorOnSurface">#CFCFCF</item>
    <item name="android:colorBackground">@color/background</item>
    <item name="colorOnBackground">#fff</item>
</style>
that is my theme and the result is this I can't see the hint of the TextInputLayout when it is unselected.
k
Hi @Mijael Viricochea try this way:
Copy code
<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/til_username"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:hint="Hint Text"
    android:theme="@style/TextInputLayoutTheme"
    app:errorEnabled="true">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/et_user_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:imeOptions="actionNext"
        android:inputType="textCapWords"
        android:paddingBottom="@dimen/padding_bottom_login_edit_text"
        android:textColor="#000000"
        android:textSize="14sp" />
</com.google.android.material.textfield.TextInputLayout>
I am keeping multiple colors in theme so that it will be easy to identify:
Copy code
<style name="TextInputLayoutTheme" parent="Widget.Design.TextInputLayout">
    <item name="android:textSize">12dp</item>
    <item name="android:textColorHint">#800080</item>
    <item name="colorAccent">#2290F9</item>
    <item name="colorControlNormal">#018001</item>
    <item name="colorControlActivated">#FFB23A</item>
</style>
Hope this helps.
👍 1
m
Thanks @Kavita I'll try it
👍 1