0

For setting default theme, I set that in application tag in the manifest file.

<application
    android:name=".App"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">

And this is the 'AppTheme' in styles.xml.

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:textColor">#0400ff</item>
    <item name="android:editTextColor">#ff0000</item>
</style>

This works in Android 5.0 and 6.0 devices. But in Android 4.x, oddly it works only for 'textColor' not 'editTextColor'. Although I set this theme, default editText color is white in android 4.x. I don't know why this problem happened. Please give me some hints!

Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154
starman3ch
  • 13
  • 5

2 Answers2

1

I answer this by myself. I found a similar question. Android set edit text style globally in theme doesn't work

It told that I should use like this

<item name="editTextColor">#ff0000</item>

instead of

<item name="android:editTextColor">#ff0000</item>.

I used it because Android Studio auto complete function recommended it.

And now I know that I have to use these BOTH!

Android 5.0 and 6.0 follow the color name="android:editTextColor", but Android 4.X follow the color name="editTextColor".

The problem has solved!

Community
  • 1
  • 1
starman3ch
  • 13
  • 5
0

try the following :

Java

Et.setTextColor()

XML

textColor="@color/yourColor"
Metronom
  • 258
  • 2
  • 14
  • I asked about the situation that when I don't set any text color in EditText like your answer. I want to set DEFAULT text color in EditText. – starman3ch Jul 19 '16 at 03:47