2

I have looked Here but am still unable to tackle my problem.

I have recently jumped into android (headfirst) and have been messing around. I would like my application to only run in Landscape mode no matter which way the screen is tilted.

My home screen is basically a page with a background and a few buttons that are aligned on the right side.

Here is my XML

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:paddingLeft = "450px"
    android:paddingRight = "60px"
    android:paddingTop="25px"
//I have tried adding orientation commands here like the one below??
    android:screenOrientation="landscape"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background = "@drawable/sign"
    >

<Button 
android:id="@+id/Button1" 
android.layout_height="60px"
android.layout_width="30px"
android:layout_height="wrap_content" 
android:layout_width="fill_parent" 
android:text="Button1"/>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<Button 
android:id="@+id/Button2" 
android.layout_height="60px"
android.layout_width="30px"
android:layout_height="wrap_content" 
android:layout_width="fill_parent" 
android:text="Button2"/>
Community
  • 1
  • 1
sealz
  • 5,348
  • 5
  • 40
  • 70
  • bahh thanks guys I was changing the wrong file. The other question i linked to would have solved the problem – sealz Jul 04 '11 at 04:38

3 Answers3

9

add this line in your manifest.xml file.

<activity android:name=".activity" android:screenOrientation="portrait"></activity>

if you want only landscape orientation then change landscape instead of portrait

see this How to set android show vertical orientation?

Community
  • 1
  • 1
Niranj Patel
  • 32,980
  • 10
  • 97
  • 133
3

Add the following property all the activites in your manifest file:

android:screenOrientation="landscape"

for example:

<activity  android:name=".MainActivity"  android:screenOrientation="landscape"  "  >
              <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

you can add this property in your application tag also in the manifest file .

hope this help you to solve your issue.

Dinesh Sharma
  • 11,533
  • 7
  • 42
  • 60
1

You need to put android:screenOrientation="landscape" on the activity tag in your AndroidManifest.xml file.

Reference: http://developer.android.com/guide/topics/manifest/activity-element.html

Niranj Patel
  • 32,980
  • 10
  • 97
  • 133
Ionuț G. Stan
  • 176,118
  • 18
  • 189
  • 202
  • that is something i have tried too but it keeps throwing me an error. I will give it another shot. – sealz Jul 04 '11 at 04:21