For a class, I'm attempting to make a basic greeting card application in Android Studio 2.2, build #AI-145.3276617, with JRE: 1.8.0_76-release-b03.
The "card" contain big image and few TextViews in a RelativeLayout.
I've attempted to test on a Nexus 5 API24 emulator and physical Nexus 5 at Android 6.0.1.
When I test the app on the emulator, the text color shows properly, but when I run on my physical device, the colors of the text are wrong.
The design view and emulator both seem to be happy with the text:
But this screen shot from my physical device has different text colors:
The xml I've included shows me attempting to use hex textColor values directly, but I've also tried to place them as resources with the same result.
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#2196F3</color>
<color name="colorPrimaryDark">#1976D2</color>
<color name="colorPrimaryLight">#BBDEFB</color>
<color name="colorAccent">#FFEB3B</color>
<color name="colorText1">#2196F3</color>
<color name="colorText2">#1976D2</color>
</resources>
My activity_main.xml file.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
tools:context="com.touchspin.hnspd.MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/background" />
<TextView
android:id="@+id/happy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Happy"
android:textSize="72sp"
android:layout_marginTop="100dp"
android:textColor="#1976D2" />
<TextView
android:id="@+id/national"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="National"
android:textSize="40sp"
android:layout_below="@id/happy"
android:textColor="#2196F3" />
<TextView
android:id="@+id/sock_puppet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Sock Puppet"
android:textSize="24sp"
android:layout_below="@id/national"
android:textColor="#1976D2" />
<TextView
android:id="@+id/day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Day!"
android:textSize="24sp"
android:layout_below="@id/sock_puppet"
android:textColor="#2196F3" />
</RelativeLayout>
I've tried cleaning the build & restarting Android Studio, resource colors & hard coded hex. I'd be grateful for any pointing in the correct direction.
For LolliPop
device or LolliPop
upper device. if the TextColor
is not display well you have disable the High contrast Text
. which is by default enable.
So To solve the Problem Go to Settings > Accessibility
and switch off the High Contrast Text
. It will solve the problem.