我有一個用行填充的ListView。這些行來自看起來一個XML文件,如:LinearLayout layout_weight
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dip"
android:weightSum="100">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/columnA"
android:layout_weight="30"
android:layout_gravity="center"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/columnB"
android:layout_weight="30"
android:layout_gravity="center"/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:id="@+id/columnC"
android:layout_weight="10"
android:layout_gravity="center"
>
</ImageView>
<CheckBox
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/columnD"
android:layout_weight="30"
android:layout_gravity="center"/>
的問題是,我想columnC項目和columnB項目非常接近在一起,讓我排在三個等距間隔出部分,即:columnA,(columnB + columnC),然後是columnD。我試圖通過使用layout_weight來實現此目的,但是上面的代碼似乎有相反的效果。柱A和柱B在左邊非常擠壓,柱C似乎在它自己的大空間中漂浮,然後柱D位於靠近柱C,其右側的空間太多。我究竟做錯了什麼? :s
打我吧,沒有意識到多少......沒有得到「加載1個新答案」,直到一會兒在我發佈之前。 – Maximus
感謝你們倆,這絕對看起來更好,但是columnD仍然顯得太靠近columnC了,右邊有太多空間:s可能與其複選框有關。 –
好吧 - 事實證明,我不得不把我的複選框包裹在一個線性佈局中以解決這個剩餘的問題,然後在線性佈局中設置重量和重力。謝謝! –