use*_*426 2 xml android textcolor textview android-layout
对于一个类,我试图在Android Studio 2.2中制作一个基本的贺卡应用程序,使用JRE:1.8.0_76-release-b03 构建#AI -145.3276617。
“卡片”在RelativeLayout中包含大图像和少量TextView。
我试图在Android 6.0.1上的Nexus 5 API24仿真器和 物理Nexus 5上进行测试。
当我在模拟器上测试应用程序时,文本颜色显示正确,但是当我在物理设备上运行时,文本颜色是错误的。
我所包含的xml显示了我尝试直接使用十六进制textColor值的方法,但是我也尝试将它们作为资源放置,结果相同。
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>
Run Code Online (Sandbox Code Playgroud)
我的activity_main.xml文件。
<?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>
Run Code Online (Sandbox Code Playgroud)
我尝试清理构建并重新启动Android Studio,资源颜色和硬编码的十六进制。对于任何指向正确方向的信息,我将不胜感激。
对于LolliPop
设备或LolliPop
上层设备。如果TextColor
显示不正确,则您已禁用High contrast Text
。默认情况下启用。
因此,要解决该问题,请转到Settings > Accessibility
并关闭电源High Contrast Text
。它将解决问题。
归档时间: |
|
查看次数: |
745 次 |
最近记录: |