3

Как правильно подготовить картинки для разных плотностей экрана? Вот два экрана: 768x1280 и 1200x1900 и оба берут картинки с папки drawable-xhdpi. У первого почти места не хватает, а у другого все отлично отображает. Как сделать, чтобы на первом экране картинки выглядели как на втором? Использую RelativeLayout. Картинки размещены относительно друг от друга.

<?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>
1
  • 1
    Думаю для вашего случая достаточно будет установить атрибут android:padding (paddingLeft, paddingTop и тд. в случае разных отступов сверху, снизу и сбоку) для корневого RelativeLayout
    – pavlofff
    27 мар 2016 в 6:14

1 ответ 1

1

Для 768x1280

drawable-xlarge-mdpi

Для 1200x1900

drawable-xlarge-hdpi

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.