Jitin
Jitin

Reputation: 344

How do I override/reset android EditText default colors?

So I am using a custom color scheme with my own colors in it. But the problem is that Although I have set the color_primary and color_secondary, when I drag in a new EditText view, the underlines, text colors and so on are still the default.
Is there a way to set my colors so that All my EditText views display them (instead of changing every View one be one.)?

Is there a default file from which the buttons take their default color values ... I was hoping if that was the case, I could just change that file itself.

Upvotes: 0

Views: 152

Answers (1)

Bhanu Prakash Pasupula
Bhanu Prakash Pasupula

Reputation: 1002

you can create style for TextInutLayout or EditText and apply the style to every Edit Text.

Below is the code for TextInput layout

first, create one common style for EditText

 <style name="TextInputFieldStyle" parent="Widget.Design.TextInputLayout">
    <item name="colorControlNormal">@color/colorSecondaryText</item>
    <item name="colorControlHighlight">@color/colorSecondary</item>
    <item name="colorControlActivated">@color/colorSecondary</item>
    <!--<item name="hintTextAppearance">@style/TextHintAppearance</item>-->
</style>

and apply the style: style="@style/TextInputFieldStyle"

  <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/ifsc_til"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:hint="@string/name"
            style="@style/TextInputFieldStyle"
            android:textColorHint="@color/colorSecondaryText">

            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/colorBlackAlpha20"
                android:paddingBottom="@dimen/edit_text_padding_bottom"
                android:inputType="textCapCharacters"
                android:textAllCaps="true"
                android:textColor="@color/colorPrimaryText"
                tools:text="Full Name" />
        </com.google.android.material.textfield.TextInputLayout>

Upvotes: 1

Related Questions