a 的文字颜色TextView
在 Marshmallow 之前的设备上始终为白色。即使我在 XML 中使用黄色或黑色,除了棉花糖之外,它始终是白色的。
在运行时,它将在所有设备上正常工作。以前,当我使用 Eclipse 时,一切正常,但在 Android Studio 中它没有从 XML 中获取属性。
我搜索过的所有问题都说要更改Theme.AppCompat
to Theme.AppCompat.Light
但这除了将白色变为黑色之外没有任何作用。我认为存在风格错误。这是我的样式代码:
<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>
这是我的 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>
我终于得到了问题的答案,实际上我正在使用最新版本的支持库,这导致了问题,我将所有内容与我同事的项目进行了比较,因为他的应用程序运行良好。
用这个
compile 'com.android.support:appcompat-v7:23.1.1'
工作室将给弹出窗口一个更新的版本也可用,但不要使用它,因为 24 版本处于 alpha 阶段。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)