2011-01-26 5 views
1

これは私のtextviewです。また、上部に画像セレクタがあります。drawableTopとtextcolorを使用したTextView

<TextView 
     android:id="@+id/icon_live_ticker" 
     android:layout_width="100dp" 
     android:layout_height="wrap_content" 
     android:drawableTop="@drawable/selector_live_ticker" 
     android:gravity="center" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textStyle="bold"    
     android:textSize="10dp" 
     android:text="@string/text_icon_live_ticker"> 
    </TextView> 

問題は、私がtextColorを設定した場合、画像セレクタの状態変化がなくなることです。

なぜ誰が説明できますか?

答えて

4

、溶液をの、textColor

<?xml version="1.0" encoding="utf-8"?> 
<selector 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
     android:state_pressed="false" 
     android:color="#777777" /> 
    <item 
     android:state_pressed="true" 
     android:color="#AAAAAA" /> 
</selector> 

ためのカラーセレクタを使用すること、ですので、modificated TextViewには、次のようになります。

<TextView 
     android:id="@+id/icon_live_ticker" 
     android:layout_width="100dp" 
     android:layout_height="wrap_content" 
     android:drawableTop="@drawable/selector_live_ticker" 
     android:gravity="center" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textStyle="bold"    
     android:textSize="10dp" 
     android:textColor="@drawable/selector_icon_text_color" 
     android:text="@string/text_icon_live_ticker"> 
    </TextView> 

私はそのための小さな記事を書いた: http://hello-android.blogspot.com/2011/01/problem-with-textcolor-by-using.html

関連する問題