gpt4 book ai didi

android - ItemTouchHelper.SimpleCallback 以编程方式滑动

转载 作者:行者123 更新时间:2023-12-02 13:19:12 25 4
gpt4 key购买 nike

我正在使用 android studios ItemTouchHelper.SimpleCallback 来刷项目,我希望项目在长时间保持时被刷,有没有办法以编程方式刷项目?我怎样才能实现这个功能?

最佳答案

在 res/anim 文件夹中定义所需的动画。

left_to_right.xml

<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>

right_to_left.xml:
<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.

希望这可以帮助。

关于android - ItemTouchHelper.SimpleCallback 以编程方式滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60361361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com