-3

how to make the layout same as for normal screen and tablet screen? can I change to linear layout with the same spaces and peding ? please help I'm new :) xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx the photo explain my problem

the home code is

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/backr"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".FreeDENTAL" >

   <Button
       android:id="@+id/buttonlec"
       android:layout_width="fill_parent"
       android:layout_height="100dp"
       android:layout_alignBottom="@+id/buttonbook"
       android:layout_alignLeft="@+id/buttonbook"
       android:layout_marginBottom="47dp"
       android:background="@drawable/cooltext1218143078" />

<Button
    android:id="@+id/buttonbook"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="158dp"
    android:background="@drawable/cooltext1218138491" />

<Button
    android:id="@+id/button1"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_alignLeft="@+id/buttonbook"
    android:layout_alignRight="@+id/buttonbook"
    android:layout_below="@+id/buttonlec"
    android:layout_marginTop="18dp"
    android:background="@drawable/cooltext1218134039" />

<Button
    android:id="@+id/button2"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="160dp"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button1"
    android:layout_below="@+id/button1"
    android:layout_marginTop="32dp"
    android:background="@drawable/cooltext1218152696" />

<Button
    android:id="@+id/button4"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button2"
    android:layout_alignRight="@+id/button2"
    android:layout_below="@+id/button2"
    android:background="@drawable/tips"
    />

<Button
    android:id="@+id/button5"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/button2"
    android:layout_alignBottom="@+id/button2"
    android:layout_alignLeft="@+id/button3"
    android:layout_alignRight="@+id/button1"
    android:background="@drawable/news" />

<Button
    android:id="@+id/button3"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="125dp"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/button4"
    android:layout_alignRight="@+id/button1"
    android:layout_below="@+id/button2"
    android:background="@drawable/cooltext1218061123" />

</RelativeLayout>
Abdwo
  • 25
  • 7

3 Answers3

0

Try working with android:layout_weight instead of fixed dp.

As can be seen here: Percentage width in a RelativeLayout

Community
  • 1
  • 1
Enigma
  • 1,699
  • 10
  • 14
  • android:layout_weight work with linearlayout I want relative and the same spaces between the buttons – Abdwo Oct 03 '13 at 13:42
  • can I use linear layout inside relative one? how – Abdwo Oct 03 '13 at 13:50
  • Yes that is possible, an example can be found here: http://stackoverflow.com/questions/17220695/how-can-i-nest-a-linear-layout-inside-a-relative-layout-to-achive-the-desired-ui – Enigma Oct 03 '13 at 14:00
0

Check dimen.xml in values-sw600dp or values-sw720dp folder for

android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"

OR: May try to change Change

android:layout_width="match_parent"
android:layout_height="match_parent"

TO

android:layout_width="fill_parent"
android:layout_height="fill_parent"
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
0

Technically, what you have is the same layout on both screens. A couple reasons things look strange on the tablet are:

  1. It doesn't look like you have different button images for the different screen sizes.
  2. You're using fill_parent for your top buttons' widths - given the variety of screen sizes possible, that's likely to end up stretching them on at least a few screens.

I'd recommend reading the guide on Supporting Multiple Screens.

Josh
  • 1,563
  • 11
  • 16