用户登录
用户注册

分享至

Android ConstraintLayout 下 RecyclerView 的底部数据显示不全解决方案

  • 作者: 书友请留步
  • 来源: 51数据库
  • 2021-09-05

ConstraintLayout可真是解决了各种层级嵌套的问题,很Nice

今天帮同事排查一个Bug,Android ConstraintLayout 下 RecyclerView 的底部数据显示,

指定了topToBottomOf 但是最后一条数据只显示一半,经过排查和解决,发现他没有指定Bottom,也就是

app:layout_constraintBottom_toBottomOf="parent"

然后高度设置为0dp就可

?

?

代码:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.luxiaofeng.ui.home.LookCarPointActivity">

    <com.luxiaofeng.widght.LuTitleLayout
        android:id="@id/title_see_look"
        app:layout_constraintTop_toTopOf="parent"
        app:titleText="@string/see"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>


    <androidx.recyclerview.widget.RecyclerView
        app:layout_constraintBottom_toBottomOf="parent"
        android:id="@+id/recyclerview"
        app:layout_constraintTop_toBottomOf="@id/title_see_look"
        android:layout_width="match_parent"
        android:layout_height="0dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
软件
前端设计
程序设计
Java相关