我有一个按钮,其中有一些形状作为背景,所以基本上我想将文本稍微移动到底部,以便产生3D效果
这是我的按钮的图像
左(未点击)和右(点击)。请忽略点击圈。
选择器XML文件:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="false"
android:state_pressed="false" android:drawable="@drawable/button_red_normal" />
<item android:state_focused="false"
android:state_pressed="true" android:drawable="@drawable/button_red_pressed" />
<item android:state_focused="true"
android:state_pressed="false" android:drawable="@drawable/button_red_focused" />
</selector>
正常状态drawable:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#FF0000" />
<corners android:radius="@dimen/button_radius" />
</shape>
</item>
<item android:bottom="@dimen/button_padding_bottom">
<shape android:shape="rectangle">
<solid android:color="@color/red" />
<corners android:radius="@dimen/button_radius" />
</shape>
</item>
</layer-list>
按下状态可绘制:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/red" />
<corners android:radius="@dimen/button_radius" />
</shape>
是否可以使用XML将文本移到底部?