如何在android中从左到右应用淡出动画
我正在尝试将淡出动画制作成如何在android中从左到右应用淡出动画,android,android-animation,Android,Android Animation,我正在尝试将淡出动画制作成视图,但我不想要标准的。我希望淡出从左到右(或从右到左)开始。你知道怎么做吗?我真的没有找到任何关于android的东西。这是我目前的代码: val fadeOut = AlphaAnimation(1f, 0f) fadeOut.interpolator = AccelerateInterpolator() fadeOut.duration = 3000L fadeOut.setAnimatio
视图
,但我不想要标准的。我希望淡出从左到右(或从右到左)开始。你知道怎么做吗?我真的没有找到任何关于android的东西。这是我目前的代码:
val fadeOut = AlphaAnimation(1f, 0f)
fadeOut.interpolator = AccelerateInterpolator()
fadeOut.duration = 3000L
fadeOut.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {
}
override fun onAnimationEnd(animation: Animation) {
mTextView.visibility = View.VISIBLE
}
override fun onAnimationRepeat(animation: Animation) {}
})
mTextView.startAnimation(fadeOut)
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<alpha
android:duration="1000"
android:fromAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="1.0" />
<translate
android:fromXDelta="100%p" android:toXDelta="0"
android:duration="500" />
</set>
据我所知,听起来你想要的是显示动画,而不是淡入/淡出动画。您最好编写自己的展示
动画
,但如果您准备接受更简单的破解,那么您可以使用ViewAnimationUtils
中提供的圆形展示动画。只需从远离左/右的地方开始循环,使循环分隔缝感觉像线性分隔缝
final View myView = findViewById(R.id.animatedImageView);
int cx = myView.getMeasuredWidth() * 2;
int cy = myView.getMeasuredHeight() / 2;
int finalRadius = (int) Math.hypot(myView.getWidth()*2, myView.getHeight());
Animator anim;
// for reveal
anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
// for hiding
// anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, finalRadius, 0);
// Do note that you'll need to factor in the 'reveal' time taken in by the extra empty space.
// You could probably get around this by creating your own interpolator,
// but in which case, you might as well just create your own reveal animation.
anim.setDuration(3000);
// make the view visible and start the animation
myView.setVisibility(View.VISIBLE);
anim.start();
检查这个链接是的,问题是我想让它从左到右淡出,而不是滑动它