2016-11-19 74 views
0

我正在創建一個Android API 10應用程序,並試圖在TextViews中設置文本的顏色。我希望將顏色設置爲紅色,但是我使用的顏色'holo_red_dark'僅適用於上面的API 14 &。在與API 10兼容的「資源」窗口中我找不到任何紅色,所以我只想知道如何解決此問題?謝謝。如何在Android Studio API 10中設置TextView文本顏色

+0

自己定義:'<顏色名稱= 「holo_red_dark」>#ffcc0000' - [來源](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/colors_holo.xml) –

回答

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

+0

這很好。謝謝 :) –

相關問題