我正在開發一個有 4 個影像按鈕的應用程式,但由于某種原因,我使用的影像被放大/裁剪得非常大,如下所示。有什么建議么?
我已經嘗試自己調整影像檔案的大小,但無論它們是 2k 還是 100x100,視覺差異都非常小。
這是其中一個按鈕的 XML 布局代碼:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageButton
android:id="@ id/imageButton1"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginEnd="520dp"
android:onClick="Click1"
android:src="@drawable/placeholder1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="SpeakableTextPresentCheck"
tools:srcCompat="@drawable/placeholder1" />
uj5u.com熱心網友回復:
在您的ImageButton
標簽集屬性中
android:scaleType="centerInside"
或者
android:scaleType="fitXY"
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/505830.html