2017-02-17 145 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"

相关问题