如何在 Android 中同时对视图进行动画、缩放和变换?

How to animate, scale and transforme Views at same time in Android?

我想实现这个,我已经阅读了有关缩放、翻译和动画的文章,但我不知道该怎么做,我尝试创建两个视图,然后尝试调整两个视图的大小,但是在白费了。

这是我的观点

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:id="@+id/parent"
android:weightSum="10"
tools:context="com.devandro.loginsignup.LandingPage">

<RelativeLayout
    android:id="@+id/loginFrame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_toRightOf="@+id/signUpFrame"
    android:background="@color/colorAccent"
    android:minWidth="80dp"
    android:onClick="viewLogin">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="30sp"
        android:rotation="0"
        android:text="Login"
        android:textColor="#FFFFFF"
        android:textSize="20sp" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/signUpFrame"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_toLeftOf="@id/signUpFrame"
    android:background="@color/colorPrimary"
    android:minWidth="80dp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_marginBottom="30sp"
        android:gravity="center"
        android:onClick="viewSignup"
        android:rotation="270"
        android:text="Signup"
        android:textColor="#FFFFFF"
        android:textSize="20sp" />

</RelativeLayout>

我认为最好的方法是使用 Scenes, but it requires Android 4.4.2 (API level 19) or higher. Just change Layout's weight property or try to use PercentRelativeLayout。您需要创建 2 个布局(场景)并在它们之间切换,并且您不必手动处理所有动画内容。

这里还有一个用于 Android Transitions API backward compatibility: Transitions Everywhere 的库(如果您的项目的最低 SDK 低于 19)。