Android ItemTouchHelper.SimpleCallback以编程方式滑动
我正在使用android studios ItemTouchHelper.SimpleCallback来刷卡项目,我希望项目在长项目保留时被刷卡,有没有办法以编程方式刷卡项目?如何实现此功能 在res/anim文件夹中定义所需的动画 从左到右.xmlAndroid ItemTouchHelper.SimpleCallback以编程方式滑动,android,kotlin,Android,Kotlin,我正在使用android studios ItemTouchHelper.SimpleCallback来刷卡项目,我希望项目在长项目保留时被刷卡,有没有办法以编程方式刷卡项目?如何实现此功能 在res/anim文件夹中定义所需的动画 从左到右.xml <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false"> <translat
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromXDelta="-100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700"/>
</set>
希望这有帮助你是否考虑使用动画模拟类似挥舞的行为?有什么特别的原因你不能做吗?没有,我没有尝试过使用动画,动画被认为是触摸/滑动模拟吗?如果是,你能告诉我怎么做吗?你可以做右/左滑动动画来查看对象。所以,只需在该视图上按一下播放动画,就可以创建您想要的内容。我会将代码发布到答案中。添加幻灯片动画或通过代码将视图移动到给定的X点不会触发触控监听器,触控监听器不会触发我用于绘制某些按钮的onDraw方法,无法找到解决此问题的任何方法:(难道你不能将你在onTouch中所做的一切都打包成一个函数,并在加载动画后调用它吗?我认为这不可行,我在用户拖动项目时绘制按钮,用动画滑动项目不会触发“onDraw”,它不会在项目滑动时绘制按钮:(我搜索了很多,但是我找不到任何方法来滑动项目并在项目滑动时绘制按钮(以编程方式,无需用户拖动)
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0%" android:toXDelta="100%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700" />
</set>
Animation slideAnim = AnimationUtils.loadAnimation(this, R.anim.right_to_left);
view.startAnimation(slideAnim);
// Where 'view' is the view object which you want to swipe
// e.g: if its a list item you want to swipe, then maybe the 'view' can be the cardview that wraps the list item.