我有一个观点。我将留在屏幕的视图。现在,我想从左侧的幻灯片动画对这个视图的画面。在Android中如何才能做到这一点?
这是我的看法
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/mView"
android:layout_width="200dp"
android:layout_height="140dp"
android:layout_gravity="center_vertical|end">
这是用于与动画从x位置移动一个TextView为0到屏幕宽度的中心的代码示例。
ObjectAnimator textViewAnimation= ObjectAnimator.ofFloat(textView,"X",0f,width/2);
textViewAnimation.setDuration(2000);
textViewAnimation.start();
您可以检查此教程的动画https://github.com/codepath/android_guides/wiki/Animations
下面是示例代码来在x轴100点移动一个TextView。你可以像动画这样你自己的看法。
ObjectAnimator animation = ObjectAnimator.ofFloat(textView, "translationX", 100f);
animation.setDuration(1000);
animation.start();