Android EditText Text Color is always white

2019-09-04 06:37发布

Good day all,

I have an issue that's truly maddening.
For some reason the textColor attribute for the EditText component in my custom theme is not taking effect.

Please note that everything else for my custom theme is working, it's just the 'textColor' part that is giving trouble.

I've seen other people with the same issue, and their 'solutions' aren't working for me.

[Articles referenced before posting this]
TextView color is always white for AppCompatActivity
Edittext color is white in appcompat 22.2

[My Code and Setup]

Android Studio Version 2.1.1

CustomTheme XML Snippet

<style name="CustomTheme" parent="@style/AppTheme">
  <item name="editTextStyle">@style/CustomEditText</item> <!-- I'm extending AppCompatActivity, hence no 'android:' prefix! -->
</style>

<style name="CustomEditText" parent="@android:style/Widget.EditText">
    <item name="android:background">@drawable/custom_edit_text</item>
    <item name="android:textColor">#333333</item>
    <item name="android:paddingLeft">12dp</item>
    <item name="android:paddingRight">12dp</item>
    <item name="android:paddingTop">8dp</item>
    <item name="android:paddingBottom">8dp</item>
</style>

Android Manifest XML Snippet

<application android:theme="@style/CustomTheme">...</application>

build.gradle (app) Snippet

android {
  compileSdkVersion 23
  buildToolsVersion "23.0.3"

  defaultConfig {
    minSdkVersion 18
    targetSdkVersion 23
  }
}

dependencies {
  compile 'com.android.support:appcompat-v7:23.1.1' <!-- I've even tried this version v7:23.4.0 -->
}

Thanks in advance for your help.

1条回答
冷血范
2楼-- · 2019-09-04 07:21

Based on a comment by youzking asking for a copy of the activity layout. I saw that I was setting the 'textColor' to white in the layout xml for the Activity. Hence, that was the issue as it was overriding the theme 'textColor'.

查看更多
登录 后发表回答