android - 单击视觉状态更改的按钮

标签 android forms animation button

有什么方法可以在 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/

相关文章:

Android Mobile Vision API检测嘴巴是否张开

安卓工作室 : findViewId not working with custom views

javascript - 比较数组图像和值,如果可以提交表单

python - Django 1.1 FormWizard,动态扩展表单

javascript - 互斥的单选按钮和相应的输入字段

html - IE 中的文字过渡动画效果问题(不知道为什么) HTML+ CSS3

swift - 如何动画移除使用 ForEach 循环创建的 View 从 SwiftUI 中的 ObservableObject 获取其数据

java - 使用button.setPressed(false)的问题;在android java代码中

android - 服务+安卓 :process "vs" IntentService

css - Bootstrap 4 : Width slightly too wide on mobile with animations (causes scroll at bottom)