0
我該如何處理上述問題?當前圖像顯得太小。我認爲我可以通過將height設置爲fill_parent並將寬度設置爲wrap_content來解決此問題,但由於寬度佔用了原始圖像的大小而不是縮放版本,因此無法解決問題。我怎樣才能解決這個問題?縮放圖像以適合ImageButton高度並保持縮小比率
<LinearLayout
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:orientation="vertical"
tools:context=".MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:src="@drawable/androidImage"
android:scaleType="center"
android:layout_weight="1"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:background="#4CAF50"
android:layout_weight="0">
<TextView
android:id="@+id/textSample"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_alignParentLeft="true"
android:text="Test"
android:textColor="#FFFFFF"
android:textSize="48sp"
android:padding="20dp"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_margin="10dp"
android:layout_centerInParent="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_mood_white"
android:scaleType="centerInside"
android:background="#100FFFFFF"/>
</RelativeLayout>
</LinearLayout>
使用Android:scaleType = 「centerCrop」 與其使用的android:scaleType = 「centerInside」 – NilayDani
仍然沒有什麼區別。與按鈕相比,圖像仍然太小。 – Armdev