java - 使用向左/向右拖动可绘制动画倒带
问题描述
我有动画可绘制
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:duration="70" android:drawable="@mipmap/scene00089"/>
<item android:duration="70" android:drawable="@mipmap/scene00088"/>
<item android:duration="70" android:drawable="@mipmap/scene00087"/>
<item android:duration="70" android:drawable="@mipmap/scene00086"/>
//......
只有当我向右(通常运行)或向左(反向)拖动时才应该播放。我已经实现了如何使用另一个具有反向动画的文件来反向播放它,但我需要解决的唯一问题是如何仅在拖放时拖动并停止播放它。
解决方案
您需要一个视图来播放动画,因此最好在布局视图层次结构中创建一个视图并在其上应用动画,如下所示。希望这会帮助你。
image.setBackgroundResource(R.anim.cubicfacetween);
AnimationDrawable animationDrawable = (AnimationDrawable) image.getBackground();
animationDrawable.start();
推荐阅读
- python - Python pandas:从 DataFrame 中删除表情符号
- database - Laravel 在同一张桌子上按孩子排序
- flutter - 编码风格问题:使用事件存储数据而不产生状态
- xml - 如何在 Oracle 的 XML 列中使用 LIKE 子句?
- php - 计算 < X 的幂的 PHP 脚本
- python-3.x - 在函数中调用函数导致执行问题
- vue.js - 将单选按钮值更改为“选中”(Vue.js、Vuetify)
- json - 我需要从两个变量之间的单行 json-data 中提取数据(Powershell)
- node.js - 使用屏幕截图诊断在 Heroku 上运行的 Puppeteer 上的错误
- javascript - Outlook 插件:如何使用 Outlook 桌面显示 console.log?