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); //------ }