如何从动画留在Android上查看幻灯片

问题描述 投票:1回答:2

我有一个观点。我将留在屏幕的视图。现在,我想从左侧的幻灯片动画对这个视图的画面。在Android中如何才能做到这一点?

这是我的看法

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/mView"
    android:layout_width="200dp"
    android:layout_height="140dp"
    android:layout_gravity="center_vertical|end">
android animation view
2个回答
1
投票

这是用于与动画从x位置移动一个TextView为0到屏幕宽度的中心的代码示例。

    ObjectAnimator textViewAnimation= ObjectAnimator.ofFloat(textView,"X",0f,width/2);
    textViewAnimation.setDuration(2000);
    textViewAnimation.start();

0
投票

您可以检查此教程的动画https://github.com/codepath/android_guides/wiki/Animations

下面是示例代码来在x轴100点移动一个TextView。你可以像动画这样你自己的看法。

 ObjectAnimator animation = ObjectAnimator.ofFloat(textView, "translationX", 100f);
 animation.setDuration(1000);
 animation.start();
© www.soinside.com 2019 - 2024. All rights reserved.