Android-ListView的最后一项不可见

标签 android xml android-layout listview

我在 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/

相关文章:

android - 背景图像放置

Android:如何针对不同的设备方向将 ViewPager 布局与非 ViewPager 布局混合使用?

android - 如何将字符串从 Retrofit 转换为我的数据类模型中的自定义对象?

.net - XML 省略号/其他语法 - 它叫什么?

java - 找不到 hibernate.cfg.xml

java - 当 <test> 标签不应超过 1 个时,JAXB 始终返回最后一个 <test> 标签

android - react native : Null extracted folder for artifact: ResolvedArtifact(componentIdentifier=com. facebook.react :react-native:0. 71.0-rc.0)

android - 如何做文字书写动画?

android - 使用 webview 显示来自 sdcard 的图像不工作

android - Android 上的缩放小部件(dp、px、屏幕尺寸)