How to prepare pictures for different screen densities? Here are two screens: 768x1280 and 1200x1900 and both take pictures from the drawable-xhdpi folder. The first one does not have enough space, while the other one displays everything perfectly. How to make the first screen pictures look like the second? I use RelativeLayout. Pictures are placed relative to each other.

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/imageView" android:background="@drawable/bgd" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:background="@drawable/google" android:id="@+id/btnGoogle" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/gmusic" android:id="@+id/btnGMusic" android:layout_alignBottom="@+id/btnGoogle" android:layout_toRightOf="@+id/btnGoogle" android:layout_toEndOf="@+id/btnGoogle" android:layout_marginLeft="5dp" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/gmail" android:id="@+id/btnGMail" android:layout_above="@+id/btnBook" android:layout_alignRight="@+id/btnBook" android:layout_alignEnd="@+id/btnBook" android:layout_marginBottom="5dp" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/gbook" android:id="@+id/btnBook" android:layout_alignTop="@+id/btnGoogle" android:layout_toRightOf="@+id/btnGoogle" android:layout_toEndOf="@+id/btnGoogle" android:layout_marginLeft="5dp" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/gplay" android:id="@+id/btnGPlay" android:layout_alignTop="@+id/btnGoogle" android:layout_toLeftOf="@+id/btnGoogle" android:layout_toStartOf="@+id/btnGoogle" android:layout_marginRight="5dp" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/gmaps" android:id="@+id/btnGMaps" android:layout_below="@+id/btnGoogle" android:layout_alignLeft="@+id/btnGPlay" android:layout_alignStart="@+id/btnGPlay" android:layout_marginTop="5dp" /> </RelativeLayout> 
  • one
    I think for your case it will be enough to set the android:padding attribute ( paddingLeft , paddingTop , etc. in the case of different indents at the top, bottom and side) for the root RelativeLayout - pavlofff

1 answer 1

For 768x1280

 drawable-xlarge-mdpi 

For 1200x1900

 drawable-xlarge-hdpi