嗨 Stackoverflow 的 friend 们。我在下面编写了 selector_button.xml
以使我的按钮在点击时更美观。但它根本不影响我的按钮。我哪里错了?
这是selector_button.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- When clicked -->
<item android:state_pressed="true"
android:state_selected="true" >
<shape >
<gradient
android:angle="90"
android:centerColor="@color/Lightgray"
android:endColor="@color/White"
android:startColor="@color/LightBlue"/>
<corners android:radius="12dip" />
<stroke
android:width="0dip"
android:color="@color/LightBlue" />
</shape>
</item>
<!-- When not clicked-->
<item >
<shape >
<gradient
android:angle="90"
android:centerColor="#ff008888"
android:endColor="@color/LightBlue"
android:startColor="@color/Lightgray"/>
<corners android:radius="12dip" />
<stroke
android:width="0dip"
android:color="@color/LightBlue" />
</shape>
</item>
</selector>
最佳答案
<!-- When not clicked-->
<item android:state_pressed="false"> <!-- you need to define ur state to false-->
<shape >
<gradient
android:angle="90"
android:centerColor="#ff008888"
android:endColor="@color/LightBlue"
android:startColor="@color/Lightgray"/>
<corners android:radius="12dip" />
<stroke
android:width="0dip"
android:color="@color/LightBlue" />
</shape>
</item>
关于android - 选择器按钮在我的 android 按钮上不起作用。如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21107784/