0

I write an app which only can set in small and medium devices and can't fit in tablet which is not looking good. How can I improve my UI by fitting my app layout in all devices.

Here is my layout code.I am submitting only one layout (xml code) so that i can follow the same procedure to other screens in app.Please help me.

<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: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="info.taramt.com.tmtsars.HomeScreen$PlaceholderFragment" 
android:background="@drawable/android">

  <TextView
      android:id="@+id/name"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_marginBottom="15dp"
      android:layout_marginLeft="20dp"
      android:layout_marginTop="5dp"
      android:layout_toRightOf="@+id/profilePic"
      android:textSize="20sp"
      android:maxLines="1"
      android:text="Name" />

  <TextView
      android:id="@+id/email"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/name"
      android:layout_alignLeft="@+id/name"
      android:layout_alignBaseline="@+id/profilePic"
      android:textSize="15sp"
      android:text="Email" />

  <TextView android:id="@+id/date"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="5dp"
      android:layout_below="@+id/email"
      android:layout_alignLeft="@+id/name"
      android:textSize="15sp"
      />

  <ImageView
      android:id="@+id/profilePic"
      android:layout_width="120dp"
      android:layout_height="120dp"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:adjustViewBounds="true"
       />

  <TextView
      android:id="@+id/hours"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/profilePic"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:layout_gravity="center"
      android:layout_marginTop="30dp"
      android:text="Time Log"
      android:textSize="20sp" />

<Chronometer 
    android:format="%s"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

    android:layout_margin="10dp"
    android:padding="2dp"
    android:id="@+id/timer"
    android:textSize="80sp"
  android:gravity="center"
    android:background="@drawable/round_rect"
    android:layout_gravity="center"
     android:layout_below="@+id/hours"
       android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"    
     />
<TextView android:id="@+id/fetchInfo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:textSize="20sp"
    android:layout_below="@+id/timer"
    android:layout_marginTop="30dp"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"

    />

Niranjan
  • 1,879
  • 2
  • 22
  • 28

1 Answers1

1

Put your main.xml layout in following folders in the /res folder of your project.

1) main.xml in layout

2) main.xml in layout-large

3) main.xml in layout-small

4) main.xml in layout-xlarge

Note: only name must be same, but inside content can be different.

Kailas
  • 7,350
  • 3
  • 47
  • 63
  • Those qualifiers are deprecated since Android 3.2. You should use sw600dp/sw720dp etc. instead. See: http://developer.android.com/guide/practices/screens_support.html#ConfigurationExamples – reVerse Aug 19 '14 at 11:03