TextView color is always white for AppCompatActivity

Viewed 2285

The text color of a TextView is always white on pre-Marshmallow devices. Even if I am using yellow or black in my XML, it is always white except on Marshmallow.

At run time it will work fine on all devices. Previously, when I was using Eclipse, everything was working find but in Android Studio it is not taking the attribute from the XML.

All of the questions I have searched say to change Theme.AppCompat to Theme.AppCompat.Light but this does nothing except change white to black. I believe there is a style mistake. Here is my style code:

 <style name="AppBaseTheme" parent="Theme.AppCompat">
        <item name="colorPrimary">@color/khaki</item>
        <item name="colorPrimaryDark">@color/khaki</item>
        <item name="colorAccent">@color/my_yellow</item>

        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

Here is my xml

 <?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="48dp">
   <ImageView
    android:id="@+id/icon1"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="12dp"
    android:layout_marginRight="12dp"
     android:src="@drawable/sj_icon"
    android:layout_centerVertical="true"/>

   <TextView
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_alignLeft="@+id/icon1"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="32dp"
    android:gravity="center_vertical"
    android:minHeight="34dp"
    android:paddingLeft="7dp"
    android:text="hello"
    android:textColor="@color/my_yellow"
    android:textSize="18sp" />

   </RelativeLayout>
2 Answers
Related