gpt4 book ai didi

android - 为什么我的 SwipeRefreshLayout 中的 ListView 在 Android 上不显示最后一个元素?

转载 作者:行者123 更新时间:2023-11-29 00:04:46 24 4
gpt4 key购买 nike

我有一个带有 Tabs 的 ViewPager,里面有一个 FragmentSwipeRefreshLayout,里面有一个 ListView,其中包含一些用于测试的元素。

我通常在底部向下滚动列表,我注意到最后一个元素没有正确显示。我搜索了正确的布局,但我仍然遇到同样的问题。

如何修复?

enter image description here

这是我的代码。

ActivityMain

<?xml version="1.0" encoding="utf-8"?>        
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"/>

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

</android.support.design.widget.CoordinatorLayout>

Fragment Job SwipeRefreshLayout

<android.support.v4.widget.SwipeRefreshLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ListView
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>

</android.support.v4.widget.SwipeRefreshLayout>

JobListRow

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:id="@+id/job_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="15-1812"
android:textSize="@dimen/text_large"
android:textStyle="bold"/>

<TextView
android:id="@+id/job_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="625 Gallatian/Sunrise"
android:textSize="@dimen/text_medium"
android:layout_below="@+id/job_id"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<TextView
android:id="@+id/job_brand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sunrise"
android:textSize="@dimen/text_small"
android:layout_below="@+id/job_description"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<TextView
android:id="@+id/job_status_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Active"
android:textSize="@dimen/text_medium"
android:textColor="@color/primaryText"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" />

</RelativeLayout>

最佳答案

这是您可以在相对布局中使用 ListView 的示例

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom"
>

<ListView
android:id="@+id/listView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>

<LinearLayout
android:id="@+id/bottom"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
></LinearLayout>

关于android - 为什么我的 SwipeRefreshLayout 中的 ListView 在 Android 上不显示最后一个元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34663756/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com