Activity orientation changes automatically on Android

前端 未结 7 2075
天命终不由人
天命终不由人 2020-12-10 01:50

I\'m developing a mobile application based on Android with minSdkVersion=15. I would like to support both orientations for tablets and only portrait for smartph

7条回答
  •  青春惊慌失措
    2020-12-10 02:41

    I found the right way to solve this issue by using:

    android:screenOrientation="locked"
    

    in every activity declared in the manifest with this issue.

    And keep using setRequestedOrientation() programatically to define if landscape or portrait orientation within onCreate() method,

    Btw, in your GitHub project, I just changed the manifest adding locked orientation like this and it finally worked:

    
    
    
        
            
                
                    
                    
                
            
            
            
        
    
    

    Hope it will help you too :)

提交回复
热议问题