liangjingkanji / BRV

[使用文档] Android 快速构建 RecyclerView, 比 BRVAH 更简单强大
http://liangjingkanji.github.io/BRV/
MIT License
2.59k stars 327 forks source link

线性布局为PageRefreshLayout分配权重后无法铺满 #276

Closed XiaoRanLiu3119 closed 1 year ago

XiaoRanLiu3119 commented 1 year ago

问题描述

使用缺省页的时候,父布局是线性布局,PageRefreshLayout的顶部与底部分别有个固定的view,此时为PageRefreshLayout设置layout_weight = 1 时,缺省页会变小,不会铺满

期望行为

线性布局下分配权重正常显示,目前改用相对布局解决的,如果是我使用问题或无必要修改可以close

如何复现

代码 `<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" xmlns:app="http://schemas.android.com/apk/res-auto" tools:context=".ui.hotel.fragment.NotUploadFragment" android:orientation="vertical">

<com.hjq.bar.TitleBar
    android:layout_width="match_parent"
    android:layout_height="44dp"
    app:leftIcon="@drawable/ic_menu_36"
    app:title="旅馆信息查询" />

<LinearLayout
    android:layout_width="match_parent"
    android:background="#f3f2f7"
    android:gravity="center_vertical"
    android:paddingVertical="6dp"
    android:paddingHorizontal="10dp"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:text="开业"
        android:drawableLeft="@mipmap/ic_circle_white"
        android:drawableTint="@color/status_open"
        android:gravity="center"
        android:layout_height="wrap_content"/>

</LinearLayout>

<com.drake.brv.PageRefreshLayout
    android:id="@+id/page"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</com.drake.brv.PageRefreshLayout>

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="10dp"
    android:paddingVertical="6dp"
    android:background="@color/colorPrimary"
    tools:text="辖区内旅馆:共48家"
    android:textColor="@color/white"
    />

`

任何业务相关问题没有fork仓库复现问题一律无法解决, 凭空猜测只会让问题晦涩难懂, 大量耽误项目维护时间

截图

erro erro loading loading 正常显示 正常

异常堆栈信息或者手机截图/视频(拖拽到输入框即可上传)

版本

liangjingkanji commented 1 year ago

建议你fork本仓库在sample中复现该问题, 否则会让我陷入猜测中浪费很多精力. 会导致我无法完成更多的bug和开源项目新需求

liangjingkanji commented 1 year ago

我修改demo中的RefreshFragment布局文件后正常显示, 无法复现你描述的问题

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center_vertical"
        android:paddingLeft="16dp"
        android:text="一旦刷新数据成功后下拉刷新不会再会显示错误页面"
        android:textColor="@color/textSecond"
        android:textSize="12dp" />

    <com.drake.brv.PageRefreshLayout
        android:id="@+id/page"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </com.drake.brv.PageRefreshLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center"
        android:text="底部" />

</LinearLayout>
XiaoRanLiu3119 commented 1 year ago

我修改demo中的RefreshFragment布局文件后正常显示, 无法复现你描述的问题

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center_vertical"
        android:paddingLeft="16dp"
        android:text="一旦刷新数据成功后下拉刷新不会再会显示错误页面"
        android:textColor="@color/textSecond"
        android:textSize="12dp" />

    <com.drake.brv.PageRefreshLayout
        android:id="@+id/page"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </com.drake.brv.PageRefreshLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center"
        android:text="底部" />

</LinearLayout>

我下了demo也修改了确实没问题,不过我将demo的布局复制过来还是会出现,目前未找到原因,我再找找看 `<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:gravity="center_vertical"
        android:paddingLeft="16dp"
        android:text="一旦刷新数据成功后下拉刷新不会再会显示错误页面"
        android:textSize="12dp" />

    <com.drake.brv.PageRefreshLayout
        android:id="@+id/page"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </com.drake.brv.PageRefreshLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="底部布局"/>
</LinearLayout>

` demo布局

liangjingkanji commented 1 year ago

你得考虑fragment外层是什么布局

XiaoRanLiu3119 commented 1 year ago

我擦,蠢哭了,感谢指点,用了竖向的viewpager2,结果高度是wrap_content,就盯着这页看了