我的列表視圖中只有兩個項目,它覆蓋了屏幕的一半,但listview仍然顯示滾動。我已經設置高度WRAP_CONTENT刪除列表視圖中的滾動
佈局代碼如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listLikeWhatsapp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:divider="@android:color/transparent"
android:dividerHeight="10.0sp"
/>
</LinearLayout>
我不想滾動出現在列表視圖,因爲它只有兩個項目,沒有必要顯示。我不確定是什麼導致滾動出現。
任何幫助將不勝感激。
請多關照
UPDATE
這是我行項目的xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="@drawable/roundedshape"
android:alpha="0.7">
<ImageView
android:id="@+id/icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:contentDescription="desc"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:src="@drawable/ic_insert_emoticon_black_48dp"
/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/icon"
android:paddingBottom="5dp"
android:text="Assignments"
android:textStyle="bold"
android:textSize="18sp"
android:textColor="#000"/>
<TextView
android:id="@+id/last_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/title"
android:layout_below="@+id/title"
android:text="Last Update : 01-01-2017"
android:textSize="13sp"
android:textColor="#696969"/>
<TextView
android:id="@+id/unread_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/title"
android:layout_alignBottom="@+id/title"
android:layout_alignParentRight="true"
android:text="04"
android:textSize="12sp"
android:background="@drawable/shape_circular"
android:padding="5dp"
android:textColor="#FFF"
android:textStyle="bold"
android:layout_marginRight="5dp"
/>
</RelativeLayout>
嘗試添加了android:layout_height = 「match_parent」 的地方WRAP_CONTENT的 –
嗯,我想添加這個列表視圖下面的TextView。通過應用match_parent將不會顯示textview below.Correct? – Anjum
1.儘量不要使用'fill_parent'。 2.你可以上傳xml的行項目嗎? –