我有一個xml佈局作爲ListView中的項目。事情是:當它被添加到那裏時,該項目的寬度不會延伸到match_parent
,而是包裝內容。它用在ListView中,所以它的寬度需要是match_parent
。我一直在閱讀關於它所有的stackoverflow,嘗試每個解決方案availible,但我有零結果:layout_weight
設置爲1對我的佈局沒有任何影響,拉伸列給了我在寬度方面最好的結果,但在佈局本身它慘敗。TableLayout拒絕match_parent
這裏有什麼可以做的嗎?
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<TableRow
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<CheckBox
android:id="@+id/trackCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:clickable="false"
android:duplicateParentState="true" />
<TextView
android:id="@+id/trackNumberText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="00."
android:textColor="@android:color/black"
android:textSize="18sp" />
<TextView
android:id="@+id/trackTitleText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_weight="1"
android:text="Title"
android:textColor="@android:color/black"
android:textSize="18sp" />
</TableRow>
<TableRow
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="@+id/trackArtistText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_weight="1"
android:text="Artist" />
</TableRow>
</TableLayout>
listview在哪裏?和上面的XML你使用的ListView的孩子? – Ankita