为了设置默认主题,我在清单文件的application标签中设置了它。
<application
android:name=".App"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
这就是AppTheme&#39;在styles.xml中。
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:textColor">#0400ff</item>
<item name="android:editTextColor">#ff0000</item>
</style>
适用于Android 5.0和6.0设备。 但是在Android 4.x中,奇怪的是它只适用于&#39; textColor&#39;不是&#39; editTextColor&#39;。虽然我设置了这个主题,但默认的editText颜色在android 4.x中是白色的。 我不知道为什么会出现这个问题。 请给我一些提示!
答案 0 :(得分:0)
尝试以下方法:
Java
Et.setTextColor()
XML
textColor="@color/yourColor"
答案 1 :(得分:0)
我自己回答这个问题。我发现了类似的问题。 Android set edit text style globally in theme doesn't work
它告诉我应该像这样使用
a:hover:before
而不是
<item name="editTextColor">#ff0000</item>
我使用它是因为Android Studio自动完成功能推荐它。
现在我知道我必须使用这两个!
Android 5.0和6.0遵循颜色 name =“android:editTextColor”,但Android 4.X遵循颜色 name =“editTextColor”。
问题已经解决了!