Я пытаюсь добавить 6 изображений в качестве ImageButtons, но эти изображения вертикально растянуты. Смотрите рисунок ниже:Растянутые изображения в LinearLayout
Как вы можете видеть на картинке всех imagebutons вертикально вытянутые. Я поместил их в drawable-xxxhdpi. Разрешение каждого изображения составляет 512x512. Я также попытался поместить их в mipmap-xxxhdpi или xxhdpi, но без разницы. Вот мой код:
<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="#DCDCDC"
tools:context="MainActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="15dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3.4">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1" />
<ImageButton
android:id="@+id/radio_channel_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/background_radio_channel_one"
android:scaleType="fitXY" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1" />
<ImageButton
android:id="@+id/radio_channel_2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/background_radio_channel_two"
android:scaleType="fitXY" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1" />
<ImageButton
android:id="@+id/radio_channel_3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/background_radio_channel_three"
android:scaleType="fitXY" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="3.4">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1" />
<ImageButton
android:id="@+id/radio_channel_4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/background_radio_channel_four"
android:scaleType="fitXY" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1" />
<ImageButton
android:id="@+id/radio_channel_5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/background_radio_channel_five"
android:scaleType="fitXY" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1" />
<ImageButton
android:id="@+id/radio_channel_6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/background_radio_channel_six"
android:scaleType="fitXY" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1" />
</LinearLayout>
</LinearLayout>
Любые предложения, чтобы они выглядели нормально не растягивается? Все эти изображения в формате PNG.
размеры починки в поле зрения изображения: ширина = 512 и высота = 512 –
попробовать удаление андроида: scaleType = «fitXY» –