Disable default animation from Portrait to Landscape

后端 未结 8 1070
庸人自扰
庸人自扰 2020-11-27 03:30

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.

This app has one s

相关标签:
8条回答
  • 2020-11-27 04:16

    You can set in the AndroidManifest a property called android:configChanges where you can decide which changes you want to manage in code. In this way, the rotation change animation will be disabled and you can handle it as you want in the method onConfigurationChanged of your Activity.

    <activity
        android:name=".MySuperClass"
        android:label="@string/read_qrcode"
        android:screenOrientation="portrait"
        android:configChanges="orientation" />
    
    0 讨论(0)
  • 2020-11-27 04:16

    You might have tried this already, but just in case:

    Try defining a "do nothing" animation and call overridePendingTransition() with its id. Maybe something like:

        <set xmlns:android="http://schemas.android.com/apk/res/android" 
             android:fillAfter="true">
            <translate
                android:fromXDelta="0"
                android:toXDelta="0"
                android:duration="100" />
        </set>
    

    Sorry, I didn't have a Galaxy device to test with :)

    0 讨论(0)
提交回复
热议问题