,你可以在你的XML使用requiresFadingEdge屬性。 做一個列表視圖佈局內與此屬性:
android:fadingEdge="horizontal"
android:fadingEdgeLength="30dp"
android:fillViewport="false"
android:requiresFadingEdge="vertical"
在其頂部和底部,從而加載列表視圖中您的項目,將已經消失的邊界像下面這個圖片:
fading edge list
所以你的代碼應該是這樣的:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/th"
tools:context="com.example.maghari_se.testfading.MainActivity">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_alignParentBottom="true"
android:visibility="visible"
android:fadingEdge="horizontal"
android:fadingEdgeLength="30dp"
android:fillViewport="false"
android:requiresFadingEdge="vertical">
</ListView>
偉大的回答,拯救了我的一天! – MohammadReza