有什么方法可以在 Android 中为按钮设置动画,以便在您单击它时将按钮的背景更改为按下的图像?
我只使用背景属性在表单按钮上显示图像。
最佳答案
使用此 XML:将其保存在 drawable 文件夹中并设置为背景 drawable。
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" android:drawable="@drawable/category_listing_bg_img" />
<item android:state_pressed="true" android:drawable="@drawable/category_listing_bg_img_pressed" />
</selector>
关于android - 单击视觉状态更改的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10425741/