如何在Android中的ListView和ImageView之间创建旋转3D动画



我想在Android中的listView和ImageView之间制作一个横梁3D动画,是否有任何库或示例代码?我是Android开发的新手,所以我不知道该如何使这种事情动画。

此库可以帮助您:https://github.com/nipun-birla/swipe3drotateview

用法中提到

在您的build.gradle(app)

中添加依赖关系
dependencies {
    compile 'com.github.nipun-birla:Swipe3DRotateView:0.0.1'
}

根据需要将Swipe3DrotateView放在布局中:

<com.nipunbirla.swipe3drotateview.Swipe3DRotateView
    android:id="@+id/rotateView"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
    //Put the backview as first child
    <FrameLayout
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_gravity="center"
        android:background="#934567">
    </FrameLayout>
    //Put the frontview as second child
    <FrameLayout
        android:layout_gravity="center"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:background="#134567">
    </FrameLayout>
</com.nipunbirla.swipe3drotateview.Swipe3DRotateView>

在您的活动中找到视图:

Swipe3DRotateView swipe3DRotateView = findViewById(R.id.rotateView);

如果允许X旋转设置:

swipe3DRotateView.setIsXRotationAllowed(true);

如果允许旋转设置:

swipe3DRotateView.setIsYRotationAllowed(true);

检查是否允许X旋转:

boolean isXAllowed = swipe3DRotateView.isXRotationAllowed();

检查是否允许旋转:

boolean isYAllowed = swipe3DRotateView.isYRotationAllowed();

设置动画持续时间,默认值为1000毫米

swipe3DRotateView.setAnimationDuration(1000);

将动画侦听器设置在视图上,使用:

swipe3DRotateView.setHalfAnimationCompleteListener(halfListener);

要在后面的视图上设置动画侦听器,请使用:

swipe3DRotateView.setCompleteAnimationCompleteListener(fullListener);

最新更新