禁用从纵向到横向的默认动画 [英] Disable default animation from Portrait to Landscape

查看:23
本文介绍了禁用从纵向到横向的默认动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个正常"活动的应用,可以横向或纵向运行.它们专为肖像画而设计,主要用于肖像画.

I have an app with several 'normal' activities which can run on either landscape or portrait. They are designed for and mostly used on portrait.

此应用有一个活动,它使用相机并锁定为横向.我通过将图像和文本旋转 90 度来模拟"这个活动是纵向的,所以它看起来像其他活动.

This app has one single activity which uses the camera and is locked on landscape. I 'simulate' this activity is on portrait by rotating images and texts 90 degree, so it looks like the rest of activities.

在某些设备上,例如三星 Galaxy Tab 7 和 Galaxy S3,在从正常人像活动切换到相机横向活动并返回时会显示旋转动画.这让用户感到困惑,因为横向活动模拟的是纵向.

On some device, such as Samsung Galaxy Tab 7 and Galaxy S3, a rotation animation is shown when going from a normal portrait activity to camera landscape activity and back. This is confusing for user because landscape activity simulates being on portrait.

有没有办法去除这个旋转动画?理想情况下,我想将默认纵向动画更改为纵向动画,但只需删除旋转动画就足够了.

Is there a way to remove this rotation animation? Ideally I'd like to change to default portrait to portrait animation, but just removing rotation animation would be enough.

我试过了

overridePendingTransition(0, 0);

该方法的其他变体,但没有成功.

an other variations of that method without success.

[添加]

根据@igalarzab、@Georg 和 @Joe 的建议,我已经做到了(仍然没有运气):

Following suggestions by @igalarzab, @Georg and @Joe, I've done this (still with no luck):

  • 在清单中添加了 android:configChanges="orientation|screenSize"
  • 添加了 onConfigurationChanged
  • 创建了一个什么都不做的虚拟动画并添加了 overridePendingTransition(R.anim.nothing, R.anim.nothing);

我得到了这些结果:

  • onConfigurationChanged 仅在旋转相同的 Activity 时调用(纵向上的 Activity A -> 横向上的 Activity A).但是当从纵向活动 A -> 横向活动 B 时不会调用它
  • 这会阻止 Activity 在旋转时重新启动,但不会移除旋转动画(在 Galaxy S3、Galaxy Nexus、Galaxy Tab 7.0 和 Galaxy Tab 10.1 上测试)
  • overridePendingTransition(R.anim.nothing, R.anim.nothing);移除了正常的过渡(人像-> 人像和风景-> 风景),但没有移除旋转动画(人像-> 风景,反之亦然).

[视频]

我上传了一个视频,其中显示了我想禁用的动画.当将手机保持纵向时从相机活动(锁定为横向)更改为其他活动时会发生这种情况:

I've uploaded a video that shows animation I want to disable. This happens when changing from camera activity (locked to landscape) to other activity while holding phone on portrait:

http://youtu.be/T79Q1P_5_Ck

推荐答案

抱歉没有办法控制旋转动画.这是在你的应用程序之外完成的,在窗口管理器的深处,它截取当前屏幕的屏幕截图,调整大小并重建它背后的 UI,然后运行一个内置的动画从原始屏幕截图过渡到新的重建用户界面.当屏幕旋转发生变化时,无法修改此行为.

Sorry there is no way to control the rotation animation. This is done way outside of your app, deep in the window manager where it takes a screenshot of the current screen, resizes and rebuilds the UI behind it, and then runs a built-in animation to transition from the original screenshot to the new rebuilt UI. There is no way to modify this behavior when the screen rotation changes.

这篇关于禁用从纵向到横向的默认动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆