0

As mentioned here Android set edit text style globally in theme doesn't work I have tried changing styles in theme file but globally it does not work. When I add it on individual component it works

My theme

<resources
    xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.Comp" parent="Theme.MaterialComponents.DayNight.NoActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/purple_500</item>
        <item name="colorPrimaryVariant">@color/purple_700</item>
        <item name="colorOnPrimary">@color/white</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_700</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
        <!-- Customize your theme here. -->
        <item name="android:buttonCornerRadius">20dp</item>
        <item name="android:backgroundTint">@color/black</item>
        <item name="editTextStyle">@style/edittext</item>
    </style>
    <style name="redButton" parent="android:Widget.TextView">
        <item name="cornerRadius">12dp</item>
        <item name="backgroundTint">#f89840</item>
        <item name="elevation">20dp</item>
        <item name="addElevationShadow">true</item>
    </style>
    <style name="edittext" parent="android:Widget.EditText">
        <item name="android:background">@drawable/editextborder</item>
        <item name="android:textColor">@color/purple_500</item>
        <item name="android:textSize">27sp</item>
        <item name="hintTextColor">@color/purple_200</item>
        <item name="borderRound">2dp</item>
    </style>
</resources>
app
  • 15
  • 3

2 Answers2

0

For example, here's how to apply the Android Support Library's Material Design "dark" theme to the whole app:

<manifest ... >
<application android:theme="@style/Theme.AppCompat" ... >
</application>

And here's how to apply the "light" theme to just one activity:

<manifest ... >
<application ... >
    <activity android:theme="@style/Theme.AppCompat.Light" ... >
    </activity>
</application>
  • thanks for your comments, I want to set style for all EditText's by adding "edittext" style in theme.xml, but it does not reflect, however when I individually add style attribute to each EditTexts it does work, please see above code and style "edittext" – app Jun 17 '23 at 12:44
0

Its working in latest Android Studio, after updating.

app
  • 15
  • 3
  • Pls don’t add updates as answers. You can add them as comments to the parent question – Dinux Jun 18 '23 at 06:50