單項如果我有一個的ListView的ArrayAdapter一個單項目,我想舒展一個項目遍佈的ListView高度(所以我有一個項目在屏幕中心的文字)。的ListView - 伸展在整個ListView的高度
像這樣:
這真是很容易與RecyclerView做(上圖),但在我的情況我買不起現在RecyclerView重建的ListView屏幕。我嘗試將佈局項目的高度設置爲屏幕高度「match_parent」或代碼中,覆蓋80dp值。它並沒有對我的情況產生任何影響,結果是這樣的:
這是我正在創建一個ArrayAdapter:
string[] noResultsItem = { Resources.GetString(Resource.String.no_network) };
playlistListView.Adapter = new ArrayAdapter<string>(this, Resource.Layout.no_result_row, Resource.Id.textTop, noResultsItem);
這是一個ArrayAdapter項目佈局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="80dp"
android:id="@+id/noResultsRow">
<TextView
android:id="@+id/textTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textSize="18dip"
android:textColor="#ffffff"
android:text=""
android:gravity="center_horizontal" />
</RelativeLayout>
我可以想象與隱藏和顯示的ListView和與將被居中一個TextView代替它的溶液,但我不喜歡第在很多解決方案。
檢查這個http://stackoverflow.com/questions/13070361/single-row-to-fill-parent-listview-height –
@AbidKhan歡呼聲,不知何故之前沒有看到,我現在就試試看 –
你可以發表你的活動代碼嗎? – FAT