0
点赞
收藏
分享

微信扫一扫

一、RecyclerView中最后一条数据不显示的解决办法

一、问题

  最近在做一个小玩意时,用到RecyclerView,并且我需要在屏幕底部显示一个菜单,目标效果如下:
一、RecyclerView中最后一条数据不显示的解决办法_android
  但是,实际在做的过程中遇到以下问题:

  1. RecyclerView中最后一条数据不显示,如下:
    一、RecyclerView中最后一条数据不显示的解决办法_数据_02
  2. 数据被底部条幅遮挡,如上图。

二、解决办法

  在 RecyclerView 上再嵌套一层 RelativeLayout 然后添加一下属性这样就OK:

android:descendantFocusability="blocksDescendants"

关于这个属性的说明,参见​​android:descendantFocusability用法简析​​ 具体代码如下:

<RelativeLayout
android:descendantFocusability="blocksDescendants"
app:layout_constraintTop_toBottomOf="@id/txt_num_reminder"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="@id/show_finished"
android:layout_width="0dp"
android:layout_height="0dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/main_rv"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>


举报

相关推荐

0 条评论