0

I have created activity but both have different look.

Image of Nexsus 10

white Space at bottom

Image of 320 x 480 Image

enter image description here

At first image it shows too much spaces at bottom . how can I resolve that problem ? How do i make that responsive.

Thank you in advance

Shabbir Dhangot
  • 8,954
  • 10
  • 58
  • 80

3 Answers3

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

Adam Radomski
  • 2,515
  • 2
  • 17
  • 28
  • your layout files designed for selected screen params. Read [this](http://developer.android.com/guide/practices/screens_support.html) – Adam Radomski Jan 30 '14 at 12:21
  • add your modified layouts for each resolutions put in corresdponding folders – Deniz Jan 30 '14 at 12:21
  • So you should write layout in that way that it can be reusable. Use [weight](http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html#attr_android:layout_weight) param in layout it helps a lot. – Adam Radomski Feb 04 '14 at 06:50
1

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)

Andy Res
  • 15,963
  • 5
  • 60
  • 96
1

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"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
<TextView android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:text="Login"
    android:gravity="center"/>
<ImageView android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="2"
   android:src="@drawable/ic_launcher"
    android:gravity="center"/>
<EditText android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:hint="Enter User Name"/>
<EditText android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:hint="Enter Password"/>
<TextView android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="2"
    android:text="Large Text"
    android:gravity="center_vertical"/>
<Button android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:text="Login"/>
<View android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1"/>
<LinearLayout android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:orientation="horizontal">
    <Button android:layout_width="0dip"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:text="Register"/>
    <Button android:layout_width="0dip"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:text="Help"/>
</LinearLayout>
<View android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1"/>
</LinearLayout>
MGDroid
  • 1,659
  • 2
  • 17
  • 32