我試圖弄清楚如何在觸摸時將外部發光添加到TextView
。我正在使用的方法是使用選擇器,但它似乎沒有工作。如何在TextView上使用自定義選擇器樣式
我有以下結構
佈局\ HomeView.axml
<TextView
android:id="@+id/textview1"
android:clickable="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
style="@drawable/control_selector_state" />
繪製\ control_selector_state.xml
<!-- yes these are all the same for testing purposes -->
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
style="@style/control_style_focused"/>
<item android:state_focused="true"
android:state_pressed="true"
style="@style/control_style_focused" />
<item android:state_pressed="true"
style="@style/control_style_focused" />
<item style="@style/control_style_focused" />
</selector>
值\ styles.xml
<resources>
<style name="control_style_focused">
<item name="android:shadowColor">#0000ff</item>
<item name="android:textColor">#ff0000</item>
<item name="android:shadowDx">0.0</item>
<item name="android:shadowRadius">8</item>
</style>
</resources>
我遇到的問題是我的TextView文本是白色的,而且樣式似乎沒有應用。
我該如何得到這種風格適用於我的TextView?
將shadowDx設置爲0.5,看看會發生什麼。 0.0完全置於小部件之下。 –
0.0的陰影是模仿發光而不是陰影。 –