Nikhilkumar Waghaye
Nikhilkumar Waghaye

Reputation: 87

Not proper view in landscape

I am having a settings page in my application.In potrait all the fields are showing properly but when I switch to landscape mode the fields height are reducing and the hint of the fields are hiding which is not what I want.

I dont why it is happening.

It is my xml file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layoutsettings"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <Button
        android:id="@+id/Button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="40sp"
        android:layout_marginRight="40sp"
        android:gravity="center_horizontal"
        android:padding="10sp"
        android:text="Signin with FB" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/UserFirstName"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:hint="FName"
            android:textSize="15sp" />

        <EditText
            android:id="@+id/UserLastName"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:hint="LName"
            android:textSize="15sp" />
    </LinearLayout>

    <EditText
        android:id="@+id/PhoneNumber"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:hint="PhoneNumber"
        android:inputType="number"
        android:phoneNumber="true"
        android:textSize="15sp" />

    <EditText
        android:id="@+id/EmailAddress"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:hint="EmailAddress"
        android:textSize="15sp" />

    <EditText
        android:id="@+id/AddressLine1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:hint="Address Line 1"
        android:textSize="15sp" />

    <EditText
        android:id="@+id/AddressLine2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:hint="Address Line 2"
        android:textSize="15sp" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/Locality"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:hint="Locality"
            android:textSize="15sp" />

        <EditText
            android:id="@+id/City"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:hint="City"
            android:textSize="15sp" />
    </LinearLayout>

    <EditText
        android:id="@+id/PinCode"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:height="30dp"
        android:layout_weight="0.5"
        android:hint="PinCode"
        android:inputType="number"
        android:textSize="15sp" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/Feedback"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="Feedback"
            android:textSize="17sp"
            android:layout_marginLeft="20dp" />

        <RatingBar
            android:id="@+id/ratingbar"
            style="@style/CustomRatingBar"
            android:layout_width="wrap_content"
            android:layout_height="50px"
            android:layout_marginRight="20sp" />
    </LinearLayout>

</LinearLayout>

If anybody can tell me what to do.

Thanks.

Upvotes: 0

Views: 128

Answers (1)

Rahul Gupta
Rahul Gupta

Reputation: 5295

You need to create another folder in res called layout-land and add the same xml with the same code and arrange it accordingly. Then when you rotate your device/emulator then the xml in layout-land will inflate on your device/emulator

Upvotes: 1

Related Questions