我创建了AnimatorSet s1
。
我想使用s1 AnimatorSet
代替R.anim.slide_in_top
。
如何告诉transaction
使用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();
}
答案 0 :(得分:1)
将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();