Skip to content Skip to sidebar Skip to footer

Layout Difference For Activity

I have created activity but both have different look. Image of Nexsus 10 Image of 320 x 480 Image At first image it shows too much spaces at bottom . how can I resolve that probl

Solution 1:

Checkout this

Basically:

keep diffrent versions of your layout in folders in example

 layout-hdpi
 layout-mdpi 
 layout-other_selector_that_you_want

etc

Solution 2:

You will need to make the login page for both handset and tablet devices, and tweak the layouts accordingly.

The simplest case would be to have the layout for the smartphones stored in res/layout/login.xml and for the tablets in res/layout-large/login.xml Having these layouts separated, try to add some padding for the layout of tablet version and center the layout in the middle of the screen, I believe it will look much better.

(if you don't have the folder layout-large in res directory, you will need to create it manually)

Solution 3:

Well it seems you are wrapping height. If you are talking about ratios You should use weight in your layout instead of wrapping height.

Demo code

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><TextViewandroid:layout_width="fill_parent"android:layout_height="0dip"android:layout_weight="1"android:text="Login"android:gravity="center"/><ImageViewandroid:layout_width="fill_parent"android:layout_height="0dip"android:layout_weight="2"android:src="@drawable/ic_launcher"android:gravity="center"/><EditTextandroid:layout_width="fill_parent"android:layout_height="0dip"android:layout_weight="1"android:hint="Enter User Name"/><EditTextandroid:layout_width="fill_parent"android:layout_height="0dip"android:layout_weight="1"android:hint="Enter Password"/><TextViewandroid:layout_width="fill_parent"android:layout_height="0dip"android:layout_weight="2"android:text="Large Text"android:gravity="center_vertical"/><Buttonandroid:layout_width="fill_parent"android:layout_height="0dip"android:layout_weight="1"android:text="Login"/><Viewandroid:layout_width="fill_parent"android:layout_height="0dip"android:layout_weight="1"/><LinearLayoutandroid:layout_width="fill_parent"android:layout_height="0dip"android:layout_weight="1"android:orientation="horizontal"><Buttonandroid:layout_width="0dip"android:layout_height="fill_parent"android:layout_weight="1"android:text="Register"/><Buttonandroid:layout_width="0dip"android:layout_height="fill_parent"android:layout_weight="1"android:text="Help"/></LinearLayout><Viewandroid:layout_width="fill_parent"android:layout_height="0dip"android:layout_weight="1"/></LinearLayout>

Post a Comment for "Layout Difference For Activity"