繁体   English   中英

Android在两个活动之间旋转动画?

[英]Android rotate animation between two activity?

如何在两个活动之间放置旋转动画。当开始活动时,下一个活动以旋转动画开始

这是一个关于如何在两个活动之间进行转换时添加动画的教程 但是,您不想使用文章中的翻译动画,而是使用旋转动画。 有关动画的更多信息,请查看此文档

把这两件事放在一起,这就是你需要做的。 首先,在您调用开始新活动的地方执行以下操作:

//Calls a new Activity  
startActivity(new Intent(this, NewActivity.class));  

//Set the transition -> method available from Android 2.0 and beyond  
overridePendingTransition(R.anim.rotate_out,R.anim.rotate_in);

然后在xml中创建以下两个动画:

rotate_out.xml

<?xml version="1.0" encoding="utf-8"?>   
<set xmlns:android="http://schemas.android.com/apk/res/android">  
   <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />  
   <rotate android:fromDegrees="0" android:toDegrees="90" android:pivotX="25%" />
</set>

rotate_in.xml

<?xml version="1.0" encoding="utf-8"?>   
<set xmlns:android="http://schemas.android.com/apk/res/android">  
   <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />  
   <rotate android:fromDegrees="90" android:toDegrees="0" android:pivotX="-25%" />
</set>

您可以使用fromDegrees,toDegrees和pivotX值来获得您想要的内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM