Android : Memaksa Display Android tetap Potrait / tetap Lanscape


public class Orientation extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {

//—change to landscape mode—

   //To change to portrait mode, use the ActivityInfo.SCREEN_ORIENTATION_PORTRAIT constant:

Besides using the setRequestOrientation() method, you can also use the android:screenOrientation attribute on the <activity> element in AndroidManifest.xml as follows to fix the activity to a certain orientation:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="" package="net.learn2develop.UIExample" android:versionCode="1" android:versionName="1.0.0"> 
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".UIActivity" android:screenOrientation="landscape" android:label="@string/app_name"> 
<intent-filter> <action android:name="android.intent.action.MAIN" /> 
<category android:name="android.intent.category.LAUNCHER" /> 

The above example fixes the activity to a certain orientation (landscape in this case) and prevents the activity from being destroyed; that is, the activity will not be destroyed and the onCreate event will not be fired again when the orientation changes.

/*  */


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s