0
我已經創建了下面的代碼ExpandableListView:不能有我的子行的右側元素在我的ExpandableListView
<ExpandableListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:cacheColorHint="#00000000" /> <!-- This last line fixes a bug with a black background when scrolling through the list -->
定義父行的XML是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/childname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:textSize="20sp" />
</LinearLayout>
最後,定義子行的XML是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:id="@+id/childname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_weight="0.80"
android:focusable="false"
android:textSize="14sp" />
<CheckBox
android:id="@+id/check1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="0.2"
android:focusable="false" />
</LinearLayout>
我試圖完成是將CheckBox放在屏幕的右側。 在設計時,在eclipse中,元素實際上是在右邊。但是當我將它安裝在手機中時,事實並非如此。
下面是結果的截圖:http://img444.imageshack.us/img444/584/97598265.png
任何想法可能是錯誤的?
問候, 費利佩
UPDATE 以下建議,這是我做的,以有工作:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/childname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:focusable="false"
android:layout_centerVertical="true"
android:textSize="14sp" />
<CheckBox
android:id="@+id/check1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:focusable="false" />
</RelativeLayout>
謝謝,那對我有效。我將我的結果添加到了我的帖子中 – 2012-03-27 10:13:18