2017-02-17 166 views
1

我已經在ViewPager中添加了ListView,一旦加載頁面,第一個選項卡被選中並且列表的最後一項沒有第一次顯示,它的當我到下一個標籤並回來時變得可見。我希望在第一次加載時看到listview的所有項目。請幫我解決這個問題。Android-ListView的最後一項不可見

這是爲ListView的XML -

<?xml version="1.0" encoding="utf-8"?> 
<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"> 
<ListView 
    android:id="@+id/listview_categories" 
    android:layout_width="fill_parent" 
    android:divider="@color/light_gray_a1" 
    android:dividerHeight="0.667dp" 
    android:background="@color/white" 
    android:layout_height="fill_parent" /> 
</RelativeLayout> 
+1

你應該使用'match_parent',而不是'fill_Parent' –

+0

添加match_parent不能解決問題。 –

回答

2

添加底部填充這樣,改變FILL_PARENT到match_parent

<?xml version="1.0" encoding="utf-8"?> 
<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"> 
<ListView 
    android:id="@+id/listview_categories" 
    android:layout_width="match_parent" 
    android:divider="@color/light_gray_a1" 
    android:dividerHeight="0.667dp" 
    android:paddingBottom="40dp" 
    android:background="@color/white" 
    android:layout_height="match_parent" /> 
</RelativeLayout> 
1

我有這個問題。剛纔我解決了它。尋找你使用的所有佈局android:layout_weight,如果它被設置一些非零值,像android:layout_weight="1"android:layout_weight="0.91",然後將它們設置爲零這樣,

android:layout_weight="0"

相關問題