-3

I have coded the whole app and designed all the layouts in Relative Layout, but now I want to make it compatible with all the screen sizes.

Gaurav Rai
  • 370
  • 1
  • 3
  • 16

3 Answers3

5

I would recommend using the percent relative layout

It offers the following attributes which you can use to set dimensions accordingly.

  • layout_widthPercent
  • layout_heightPercent
  • layout_marginPercent
  • layout_marginLeftPercent

etc.

Dishonered
  • 8,449
  • 9
  • 37
  • 50
0

In most cases Android will automatically resize your layout to fit the screen. However, if you want to ensure that elements will be placed the way you define them to be then use different layouts for different layouts for different screen size. The configuration qualifiers you can use to provide size-specific resources are small, normal, large, and xlarge. For example, layouts for an extra-large screen should go in layout-xlarge/. Android documentation

Jan Stoltman
  • 394
  • 3
  • 15
0

Try assigning weights to UI components. Works like charm, not matter what screen size is

example

 <LinearLayout
    android:weightSum="2"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:layout_weight="1"
        android:text="1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


    <TextView
        android:layout_weight="1"
        android:text="1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


</LinearLayout>
Kiran Koravi
  • 164
  • 2
  • 11