Issue
I have a resource file containing colors which I reference from my layout file to set text color. The text is set to the assigned colors on my emulator, but the text is all set to black on my phone.
colors.xml
<resources>
<color name="myColor1">#eaf0a4</color>
<color name="myColor2">#1643a4</color>
</resources>
activity_myActivity.xml (layout)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/myActivityID"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:background="@android:color/white" >
<View
android:background="@android:color/white"
android:clickable="true"
android:elevation="2dp"
android:id="@+id/whiteBackground"
android:layout_height="match_parent"
android:layout_width="match_parent" />
<TextView
android:id="@+id/text1"
android:elevation="4dp"
android:layout_marginTop="2dp"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_height="60dp"
android:layout_width="wrap_content"
android:text="Hello world!"
android:textAlignment="center"
android:textColor="@color/myColor1"
android:textSize="12sp" />
<Button
android:background="@android:color/white"
android:id="@+id/button1"
android:layout_below="@+id/myText1"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_width="wrap_content"
android:text="Click me!"
android:textAllCaps="false"
android:textColor="@color/myColor2"
android:textSize="10sp" />
</RelativeLayout>
Does anyone understand why text is set to the right colors on my emulator, but the text is all set to black on my phone?
Solution
On your phone, Go to Settings > Accessibility and switch off the High Contrast Text. It will solve the issue.
Answered By - Akhilesh Awasthi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.