2013-05-13 38 views
0

是THR任何方式改變TextView的文本陰影顏色如何改變TextView的陰影顏色的onclick

呈三角改變文字顏色

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 

<item android:color="@color/white" android:state_focused="true"/> <!-- focused --> 
<item android:color="@color/white" android:state_focused="true" android:state_pressed="true"/> <!-- focused and pressed --> 
<item android:color="@color/white" android:state_pressed="true" /> <!-- pressed --> 
<item android:color="@color/black"/> <!-- default --> 

+0

你爲什麼不創建一個樣式,並在上面選擇將其應用於您的項目。 – Prateek 2013-05-13 06:45:27

+0

可以給我發一個樣品嗎? – 2013-05-13 06:51:32

+0

「選擇僅可用於繪製資源,而不是文本露面」 http://stackoverflow.com/a/7706405/1479968 – 2013-09-16 03:47:45

回答

1

創建styles.xml

風格
<style name="myshadowstyle"> 
    <item name="android:shadowColor">#ff8800</item> 
    <item name="android:shadowRadius">2</item> 
</style> 

現在在你的選擇XML

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 

<item style="@style/myshadowstyle" android:state_focused="true"/> <!-- focused --> 
<item style="@style/myshadowstyle" android:state_focused="true" android:state_pressed="true"/> <!-- focused and pressed --> 
<item style="@style/myshadowstyle" android:state_pressed="true" /> <!-- pressed --> 
<item android:color="@color/black"/> 
</selector> 
+0

我已經整合,但邊界並不適用 – 2013-05-13 07:25:45

+0

邊境什麼你說的是你得到文字陰影? – Prateek 2013-05-13 07:30:35

+0

是的,我需要得到文字陰影 – 2013-05-13 07:34:15

0
textView.setShadowLayer(2.0f, 0.0f, 0.0f, Color.GRAY);