如何更改onclick的textview阴影颜色

时间:2013-05-13 06:41:00

标签: android textview shadow

是更改textview文本阴影颜色的任何方式,类似于更改文本颜色

<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 -->

2 个答案:

答案 0 :(得分: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>

答案 1 :(得分:0)

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