Monday 20 June 2011

How to Set Screen Orientation portrait or landscape

Their is 2 ways to set Screen Orientation:

First Way:
In Android manifest file(manifest.xml)just add this to the activity attribute tag for portrait add this
android:screenOrientation="portrait"
For landscape :
android:screenOrientation="landscape"

Second Way:
Using code also we can set  Screen Orientation .
In Activity onCreate() method 
For Landscape:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
For  portrait:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
But you must add these line in OnCreate() and before setContentView(). in your Activity.

No comments:

Post a Comment

Android SQLite Database Viewer or Debuging with Stetho

Every Android Developer uses SQLite Database to store data into the Android Application data. But to view the data in SQLite have a lot of...