android – 如何使用xml文件设置爆炸转换
作者:互联网
我正在尝试使用explode.xml文件setEnterTransition.
我试过这个
<?xml version="1.0" encoding="utf-8"?>
<transitionManager xmlns:android="http://schemas.android.com/apk/res/android">
<transition android:transition="@transition/explode" />
</transitionManager>
还有这个
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<explode
android:duration="500"
android:interpolator="@android:interpolator/bounce" />
</transitionSet>
但爆炸动画没有用,有什么想法吗?
解决方法:
首先,在res / transition文件夹中创建名为explode.xml的爆炸转换的Transition XML.如,
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<explode
android:duration="320" />
</transitionSet>
然后,在AppTheme的styles.xml中将android:windowContentTransitions设置为true,并引用Enter和Exit的爆炸转换,如下所示:
<item name="android:windowContentTransitions">true</item>
<item name="android:windowEnterTransition">@transition/explode</item>
<item name="android:windowExitTransition">@transition/explode</item>
现在开始您的活动,
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this);
Intent intent = new Intent(MainActivity.this, SecondActivitiy.class);
startActivity(intent, options.toBundle());
标签:android,android-animation,android-transitions 来源: https://codeday.me/bug/20190828/1748738.html