[英]How to create a rotate 3D Animation between a ListView and an ImageView in Android?
我想在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);
设置是否允许Y旋转:
swipe3DRotateView.setIsYRotationAllowed(true);
要检查是否允许X旋转:
boolean isXAllowed = swipe3DRotateView.isXRotationAllowed();
要检查是否允许Y旋转:
boolean isYAllowed = swipe3DRotateView.isYRotationAllowed();
要设置动画持续时间,默认值为1000毫秒
swipe3DRotateView.setAnimationDuration(1000);
要在前面的视图中设置动画侦听器,请使用:
swipe3DRotateView.setHalfAnimationCompleteListener(halfListener);
要在后面的视图上设置动画侦听器,请使用:
swipe3DRotateView.setCompleteAnimationCompleteListener(fullListener);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.