0

I am developing a simple mobile app. The problem is with the landscape orientation. It work fine on virtual device on eclipse and in landscape mode shows all buttons. But when i run app on my mobile device in landscape mode i still not shows all buttons as it should be and last button is lost but on virtual device it work fine and shows all buttons in tabular form. Below is my code. Please check it.

My Mobile Device Android Version is - 2.3.6

Manifest.XML Code

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.example.sudoku1"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" 
        android:theme="@style/AppTheme" >
        <activity
            android:name="org.example.sudoku1.Sudoku"
            android:configChanges="orientation|keyboardHidden"

            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

res/layout/activity_sudoku.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="30dip"
    android:orientation="horizontal" >
    <LinearLayout
    android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="center">

    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="25dip"
        android:text="@string/main_title" />

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/continue_label" />

    <Button
        android:id="@+id/button2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"

        android:layout_marginTop="21dp"
        android:text="@string/new_game_label" />

    <Button
        android:id="@+id/button3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"

        android:layout_marginTop="20dp"
        android:text="@string/about_label" />

    <Button
        android:id="@+id/button4"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="29dp"
        android:text="@string/exit_label" />
</LinearLayout>
</LinearLayout>

(FOR LANDSCAPE VIEW)res/layout-land/activity_sudoku.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="15dip"
    android:orientation="horizontal" >
    <LinearLayout
        android:orientation="vertical"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:layout_gravity="center"
    android:paddingLeft="20dip"
    android:paddingRight="20dip">
        <TextView
        android:text="@string/main_title"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="20dip"
        android:textSize="24.5sp" />
        <TableLayout 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="center"
            android:stretchColumns="*">

        <TableRow>
        <Button
        android:id="@+id/button1"
        android:text="@string/continue_label" />
        <Button
        android:id="@+id/button2"
        android:text="@string/new_game_label" />
        </TableRow>

        <TableRow>
        <Button
        android:id="@+id/button3"
        android:text="@string/about_label" />
        <Button
        android:id="@+id/button4"
        android:text="@string/exit_label" />
        </TableRow>

        </TableLayout>
        </LinearLayout>
        </LinearLayout>
parsley72
  • 8,449
  • 8
  • 65
  • 98
Abhishek
  • 1,585
  • 2
  • 12
  • 15
  • on which emulator your testing and on which real device you are testing? – Goofy Aug 05 '13 at 12:21
  • You should check the resolution of your emulator and device. The button is lost because, there is not enough space to display it. Try using a scrollview or rearrange the buttons to fit the screen size. – Vamsi Challa Aug 05 '13 at 12:25
  • @Goofy i am using ANDROID "Target= Andriod 4.2.2(API Level 17), Screen Resolution 240x320". For Mobile device i am using samsung galaxy y GT-S6102 – Abhishek Aug 05 '13 at 12:44

1 Answers1

1

try android:layout_width="wrap_content" in button tag

demongolem
  • 9,474
  • 36
  • 90
  • 105
Amarnath Baitha
  • 561
  • 1
  • 6
  • 19