我想在佈局中填充任意寬度和相同高度的兩個圖像(填充設備寬度)。在佈局中組合2個圖像
這個例子大小:
- 骰子:427x427
- 多米諾:900x427
鑑於與Domino以外的圖像和骰子的目標可能是這樣的:
我的初始代碼是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#999999"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/domino" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/dice" />
</LinearLayout>
對於XLARGE屏幕的結果是:
而對於小屏幕的多米諾通吃的寬度和骰子甚至不出現。
還試圖將兩個圖像的權重設置爲1,但結果也是錯誤的,並根據屏幕大小而變化。
我該如何解決這個問題?謝謝!
你可以嘗試設置骰子的重量爲427,多米諾骨牌的重量爲900。 – yDelouis
試過了,配置這兩個圖像有相同的寬度(每個屏幕的一半) – Addev
嗨,只是一個建議,在你的情況下,如果你使用weight屬性,你必須設置寬度爲0,否則重量不起作用。你把它設置爲0嗎? – kameny