Ich versuche, 6 Bilder als ImageButtons hinzuzufügen, aber diese Bilder sind vertikal gestreckt. Siehe das Bild unten:Gestreckte ImageViews in LinearLayout
Wie Sie im obigen Bild sehen können alle imagebutons vertikal gestreckt. Ich habe sie in drawable-xxxhdpi platziert. Die Auflösung jedes Bildes beträgt 512x512. Ich habe auch versucht, sie in mipmap-xxxhdpi oder xxhdpi, aber keinen Unterschied zu platzieren. Hier ist mein Code:
<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>
Irgendwelche Vorschläge, um sie normale nicht gestreckt aussehen? Alle diese Bilder sind im PNG-Format.
fix Größen in Bildansicht: width = 512 und height = 512 –
versuchen Entfernen android: Scaletype = "fitXY" –