Android keep orientation portrait

Option 1

In the AndroidManifest.xml add ‘screenOrientation’ property in activity tag

<activity 
    - - - - - - - 
    - - - - - - -    
    android:screenOrientation="portrait" />

Option 2

In the onCreate function add the following line of code before setContentView() function

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 
        setContentView(R.layout.activity_main);

        //------

    }

 

Author: bm on November 3, 2016
Category: Android
Tags: ,

Your comment:

Your Name

Comment:




Last articles