我有4個ImageView/ImageButtons的Linearlayout。所有圖像具有相同的寬度和高度。我想此佈局總是配合父母的寬度和所有圖像用相同的縱橫比(寬度和高度)規模:在具有相同寬度和高度比的不同屏幕尺寸下調整ImageView/ImageButton的大小
我嘗試這樣做:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/item_background"
android:layout_weight="1"
android:adjustViewBounds="true"/>
// All 4 images are the same
</LinearLayout>
的問題是,之間的比例在土地/肖像的寬度和高度是不一樣的。例如,在橫向模式下,圖像被拉伸僅在x軸而不是Y軸:
我不想在代碼中去,例如僅UI的東西,我希望你能幫助我找到一種在XML中做到這一點的方法!
編輯:
添加機器人之後:scaleType = 「fitXY」 將圖像我得到這個:
,正如你所看到的是不是一個很好的解決了我想要的東西。
我編輯了Q,你可以看到這不是我想要的。 –