0
我需要創建一些圖像來填充我在XML中定義的一些ImageButton元素,並且按鈕會根據屏幕大小自動調整大小。爲動態大小的ImageButton創建圖像的建議方法是什麼?
例如,假設我使用Photoshop來創建這些圖像之一。我如何知道設置圖像的大小,分辨率,寬高比等?顯然這不是一個好主意,拉伸圖像或類似的東西,所以我有點失落。
我不知道在這種情況下它是否相關,但我會在這裏留下我的代碼,以及它的外觀截圖。
XML:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="pt.ismai.a26800.readr.MainActivity"
tools:showIn="@layout/activity_main">
<ImageButton
android:id="@+id/imageButton1"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:srcCompat="@mipmap/ic_launcher"
tools:ignore="ContentDescription" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:srcCompat="@mipmap/ic_launcher"
tools:ignore="ContentDescription" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:srcCompat="@mipmap/ic_launcher"
tools:ignore="ContentDescription" />
<ImageButton
android:id="@+id/imageButton4"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:srcCompat="@mipmap/ic_launcher"
tools:ignore="ContentDescription" />
<ImageButton
android:id="@+id/imageButton5"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:srcCompat="@mipmap/ic_launcher"
tools:ignore="ContentDescription" />
<ImageButton
android:id="@+id/imageButton6"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:srcCompat="@mipmap/ic_launcher"
tools:ignore="ContentDescription" />
<ImageButton
android:id="@+id/imageButton7"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:srcCompat="@mipmap/ic_launcher"
tools:ignore="ContentDescription" />
<ImageButton
android:id="@+id/imageButton8"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
app:srcCompat="@mipmap/ic_launcher"
tools:ignore="ContentDescription" />
</GridLayout>
佈局: