[英]How to override animation when entering in PIP mode in android
My PIPActivity
has only one image view and I am entering in PIP mode in onCreate()
ie PIPActivity
is there only to show image in PIP mode.我的
PIPActivity
只有一个图像视图,我在onCreate()
中进入 PIP 模式,即PIPActivity
仅在 PIP 模式下显示图像。 Now when I am starting PIPActivity
there is some animation that slowly transitions into PIP mode.现在,当我开始
PIPActivity
时,有一些 animation 会慢慢过渡到 PIP 模式。 During this transition, the image is getting stretched weirdly.在此过渡期间,图像被奇怪地拉伸。 To avoid this how can stop the animation when entering PIP mode?
为避免这种情况,如何在进入 PIP 模式时停止 animation? I have already tried
我已经试过了
Intent.FLAG_ACTIVITY_NO_ANIMATION
while launching activity.Intent.FLAG_ACTIVITY_NO_ANIMATION
。<item name="android:windowAnimationStyle">@null</item>
in activity theme.<item name="android:windowAnimationStyle">@null</item>
。 You may want to look at ActivityOptions and its various methods.您可能想查看ActivityOptions及其各种方法。
Create an ActivityOptions specifying a custom animation to run when the activity is displayed.
创建一个 ActivityOptions 指定自定义 animation 以在显示活动时运行。
ActivityOptions options = ActivityOptions.makeCustomAnimation(MainActivity.this, 0, 0);
startActivity(intent, options.toBundle());
Or by using setExitTransition and/or setSharedElementExitTransition .或者通过使用setExitTransition和/或setSharedElementExitTransition 。
getWindow().requestFeature(android.view.Window.FEATURE_ACTIVITY_TRANSITIONS);
//These functions define the exit transition for the calling activity.
getWindow().setExitTransition(null);
getWindow().setSharedElementExitTransition(null);
setContentView(R.layout.mainActivity);
NOTE笔记
Implement one of these in a launcher activity and NOT in PIPActivity.在启动器活动中实现其中之一,而不是在 PIPActivity 中。
Use this method and implement it on launcher activity:使用此方法并在启动器活动中实现它:
getWindow().requestFeature(android.view.Window.FEATURE_ACTIVITY_TRANSITIONS);
getWindow().setExitTransition(null);
getWindow().setSharedElementExitTransition(null);
setContentView(R.layout.mainActivity);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.