RecyclerView最后一条显示不全或显示部分的问题解决

一、问题现象

RecyclerView最后一条数据展示不全的问题

二、前提条件

使用ViewPager+Fragment+RefreshLayout+RecyclerView+constrainLayout

三、尝试解决方式

什么叫尝试解决方式,就是使用了以下方式,各种修改各种没解决。

1.recyclerview高度设置为0dp,然后添加app:layout_constraintBottom_toBottomOf="parent"

2.recyclerview用NestedScrollView包起来

3.recyclerview外套RelativeLayout

如果以上尝试都没有解决你的问题、那么好,接下来就是见证奇迹的时刻了。

四、最终解决方案

使用CoordinatorLayout+AppBarLayout修饰viewPager完美解决~话不多说半句多。请看代码

<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:id="@+id/sv_contentView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/common_content_background_color">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/ll_contentView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:elevation="0dp">

        <ai.gmtech.uicom.ui.CommonTitleBar
            android:id="@+id/commonTitleBar26"
            android:layout_width="match_parent"
            android:layout_height="44dp"
            app:title="对讲">


        </ai.gmtech.uicom.ui.CommonTitleBar>

        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tab_call"
            android:layout_width="match_parent"
            android:layout_height="44dp"
            android:background="@color/white_FFFFFFFF"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:tabIndicator="@drawable/tab_indictor_bg"
            app:tabIndicatorColor="@color/common_tv_font_color">

        </com.google.android.material.tabs.TabLayout>
    </com.google.android.material.appbar.AppBarLayout>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/bottom_view_cl"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <RelativeLayout
            android:id="@+id/view_pager_rl"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_weight="1">

            <androidx.viewpager.widget.ViewPager
                android:id="@+id/callpage_viewPager"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            </androidx.viewpager.widget.ViewPager>
        </RelativeLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

五、若有其他问题及及解决方案欢迎留言探讨

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FrancisBingo

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值