如何在Android Studio API 10

时间:2016-11-19 17:33:26

标签: java android xml

我正在创建一个Android API 10应用,我正在尝试在TextViews中设置文本的颜色。我希望将颜色设置为红色,但是' holo_red_dark',这是我使用的颜色仅适用于API 14&以上。我在“资源”中找不到任何颜色的红色。与API 10兼容的窗口,所以我只是想知道如何解决这个问题?谢谢。

1 个答案:

答案 0 :(得分:0)

您可以在res文件夹中创建colors.xml文件并定义颜色。

示例:

<?xml version="1.0" encoding="utf-8"?>
<resources>
     <item name="blue" type="color">#FF33B5E5</item>
</resources> 

并像

一样使用它
<TextView  
    android:layout_width="fill_parent" 
    android:text="@string/hello" 
    android:layout_height="wrap_content" 
    android:id="@+id/TextView01" 
    android:textColor="@colors/blue"/>

请检查:https://developer.android.com/samples/BasicMediaRouter/res/values/colors.html