gpt4 book ai didi

java - 将 AnimatorSet 添加到动态创建的 FragmentTransaction

转载 作者:行者123 更新时间:2023-11-30 02:44:41 25 4
gpt4 key购买 nike

我创建了一个 AnimatorSet s1

我想使用 s1 AnimatorSet 而不是 R.anim.slide_in_top

如何让事务使用s1

private void showsystemerror(int i){
dialog.cancel();
Systemerror frag = new Systemerror();
Bundle bundle = new Bundle();
bundle.putInt("type", i);
frag.setArguments(bundle);
final AnimatorSet s1 = new AnimatorSet();
final ObjectAnimator anim = ObjectAnimator.ofInt(frag, "x", 150,0);
anim.setDuration(500);
s1.play(anim);

FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.anim.slide_in_top, 0);
transaction.add(R.id.main, frag);
transaction.commit();
}

最佳答案

onCreate 中的这段代码添加到您的 Systemerror 类中。请务必将 returnFrag 替换为您的返回 variable

    final AnimatorSet s1 = new AnimatorSet();
final ObjectAnimator anim = ObjectAnimator.ofFloat(returnFrag, "x", 150,0);
anim.setDuration(500);
s1.play(anim);
s1.start();

关于java - 将 AnimatorSet 添加到动态创建的 FragmentTransaction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25274851/

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