我在 ViewPager 中添加了 ListView,页面加载后,第一个选项卡被选中,列表的最后一项没有第一次显示,当我转到下一个选项卡时,它变得可见后退。我想在第一次加载时查看 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>
最佳答案
像这样添加底部填充并将 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>
关于Android-ListView的最后一项不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42291542/