FAQS


How to show Activity in Portrait or in Landscape mode.

Views: 4673  |   Date: 2013-08-16 23:56:43

Answer 1

For this we need to set the android:screenOrientation attribute in manifest.
To show the Screen/Activity in Landscape mode :

   


To show the Screen/Activity in Portrait mode :
   

Answer 2

In ONCREATE Method Configuration config = getResources().getConfiguration(); onConfigurationChanged(config); public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Checks the orientation of the screen if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show(); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){ Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show(); } }

 
Submit Your Answer
  |  
 
 
 

Preview :