创建一个比较长的过渡。 TransitionManager.beginDelayedTransition();太快 [英] Creating a slower transition. TransitionManager.beginDelayedTransition(); is too fast
问题描述
我创建一个过渡。并在单击按钮时执行下面的方法。该方法改变了尺寸,图像视图的位置,并且它消失了出来。我使用 TransitionManager.beginDelayedTransition();实在是太快了。
来减缓过渡..但它仍然是走得太快。我能做些什么来过渡放缓。谢谢。
私人无效moveIcon(){
查看moveableIcon = findViewById(R.id.moveableImageView); TransitionManager.beginDelayedTransition(myLayout); //改变图标的位置 RelativeLayout.LayoutParams positionRule =新RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
positionRule.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE); positionRule.addRule(RelativeLayout.ALIGN_PARENT_LEFT,RelativeLayout.TRUE); moveableIcon.setLayoutParams(positionRule); //改变按钮的尺寸 ViewGroup.LayoutParams sizeRules = moveableIcon.getLayoutParams();
sizeRules.width = 50;
sizeRules.height = 50;
moveableIcon.setLayoutParams(sizeRules); fadeOutAndHideImage(图片);
}私人无效fadeOutAndHideImage(最终ImageView的IMG)
{
动画淡出=新AlphaAnimation(1,0);
fadeOut.setInterpolator(新AccelerateInterpolator());
fadeOut.setDuration(1000); fadeOut.setAnimationListener(新Animation.AnimationListener()
{
公共无效onAnimationEnd(动画动画)
{
img.setVisibility(View.GONE);
}
公共无效onAnimationRepeat(动画动画){}
公共无效onAnimationStart(动画动画){}
}); img.startAnimation(淡出);
}
尝试用这个方法:[beginDelayedTransition(android.view.ViewGroup,android.transition.Transition)](<一个href=\"https://developer.android.com/reference/android/transition/TransitionManager.html#beginDelayedTransition(android.view.ViewGroup\" rel=\"nofollow\">https://developer.android.com/reference/android/transition/TransitionManager.html#beginDelayedTransition(android.view.ViewGroup, android.transition.Transition))
AutoTransition autoTransition =新AutoTransition();
autoTransition.setDuration(3000);TransitionManager.beginDelayedTransition(myLayout,autoTransition);
I am creating a transition. And when a button is clicked the following method is executed. The method changed the size , position of the image view, and it fades it out. I am using TransitionManager.beginDelayedTransition(); is too fast.
to slow down the transition.. but it is still going too fast. What can i do to slow down the transition. Thank You.
private void moveIcon() {
View moveableIcon = findViewById(R.id.moveableImageView);
TransitionManager.beginDelayedTransition(myLayout);
// change the position of the icon
RelativeLayout.LayoutParams positionRule = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT ,
RelativeLayout.LayoutParams.WRAP_CONTENT);
positionRule.addRule(RelativeLayout.ALIGN_PARENT_TOP , RelativeLayout.TRUE);
positionRule.addRule(RelativeLayout.ALIGN_PARENT_LEFT , RelativeLayout.TRUE);
moveableIcon.setLayoutParams(positionRule);
// change the size of the button
ViewGroup.LayoutParams sizeRules = moveableIcon.getLayoutParams();
sizeRules.width = 50;
sizeRules.height = 50;
moveableIcon.setLayoutParams(sizeRules);
fadeOutAndHideImage(image);
}
private void fadeOutAndHideImage(final ImageView img)
{
Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setInterpolator(new AccelerateInterpolator());
fadeOut.setDuration(1000);
fadeOut.setAnimationListener(new Animation.AnimationListener()
{
public void onAnimationEnd(Animation animation)
{
img.setVisibility(View.GONE);
}
public void onAnimationRepeat(Animation animation) {}
public void onAnimationStart(Animation animation) {}
});
img.startAnimation(fadeOut);
}
Try use this method: [beginDelayedTransition(android.view.ViewGroup, android.transition.Transition)](https://developer.android.com/reference/android/transition/TransitionManager.html#beginDelayedTransition(android.view.ViewGroup, android.transition.Transition))
AutoTransition autoTransition = new AutoTransition();
autoTransition.setDuration(3000);
TransitionManager.beginDelayedTransition(myLayout, autoTransition);
这篇关于创建一个比较长的过渡。 TransitionManager.beginDelayedTransition();太快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!