2013-03-28 58 views
1

我有一個奇怪的問題與標準的Android開關組件。開關textColor不起作用

我已經指派我的自定義跟蹤和拇指繪項目 - 一切似乎看起來和工作確定,除文字顏色屬性,它始終是黑暗的(可能是主題顏色)的顏色。

試過十六進制指定顏色,作爲資源,並且如通過機器人的選擇器:文字顏色屬性。不幸的是盡一切努力未能達到

沒有人碰到這個問題就變的目標是什麼?

這裏是我的用法:

<Switch 
    android:id="@id/settings_lock_screen_compound_btn" 
    android:layout_width="97dp" 
    android:layout_height="24dp" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentTop="true" 
    android:textOff="Off" 
    android:textOn="On" 
    android:textSize="12sp" 
    android:thumb="@drawable/switch_thumb" 
    android:track="@drawable/switch_track_bg" /> 

回答

2

事實證明,你必須使用switchTextAppearance和風格定義的資源屬性textAppeareance改變(或做在Java代碼中當量)。

在開關類的文字顏色屬性是在這種情況下相當誤導但必要的,因爲類繼承(不直接地)從TextView的類

+0

參見[這裏](http://stackoverflow.com/questions/17974305/how -to-change-switch-imput-text-color-in-xml)來了解如何做到這一點的細節。 – Faisal