有没有一种方法可以创建Button
为state_pressed
时具有底边距的Android false
,而state_pressed
为{{1}时具有不具有底边距的圆角}}?
我有这个,但是当true
为state_pressed
时没有底边距:
false
编辑:添加了图片
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape
android:shape="rectangle">
<solid android:color="#B5B5B5" />
<corners android:radius="10dp" />
</shape>
</item>
<item android:state_pressed="false">
<shape
android:shape="rectangle">
<solid android:color="#FFFFFF" />
</shape>
</item>
</selector>
android:state_pressed="false"
答案 0 :(得分:1)
<selector xmlns:android="schemas.android.com/apk/res/android">
<item android:drawable="@drawable/drawable_for_pressed_state" android:state_pressed="true"/>
<item android:drawable="@drawable/drawable_for_normal_state" android:state_pressed="false"/>
</selector>
将此代码添加到可绘制文件夹中,并对不同的按钮状态使用单独的按钮可绘制对象