【问题标题】:Android-Last item of the ListView is not visibleAndroid-ListView的最后一项不可见
【发布时间】:2017-02-17 07:09:31
【问题描述】:

我已经在 ViewPager 中添加了 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>

【问题讨论】:

  • 你应该使用match_parent而不是fill_Parent
  • 添加 match_parent 并没有解决问题。

标签: android xml android-layout listview


【解决方案1】:

像这样添加底部填充并将 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>

【讨论】:

    【解决方案2】:

    我遇到了这个问题。刚才我解决了。在您使用的所有布局中查找android:layout_weight,如果它设置了一些非零值,例如android:layout_weight="1"android:layout_weight="0.91",然后像这样将它们设置为零,

    android:layout_weight="0"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-31
      • 2013-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多