【问题标题】:Why Fix Button in Bottom in Coordinator Layout scroll with recycle view in android为什么修复 Coordinatorlayout 底部的按钮在 android 中使用 recyclerview 滚动
【发布时间】:2020-08-29 14:09:50
【问题描述】:

我想在其底部有一个回收视图和一个修复按钮。 我使用协调器布局,一切正常,但是当回收视图滚动结束时,修复按钮会随着回收视图移动一点。 有什么问题??

这是我的代码..

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:background="@drawable/filter_frame"
    android:orientation="vertical">
    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/shopsList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/complete_info_order"
        android:layout_marginBottom="@dimen/_70sdp"
        android:orientation="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <Button
        android:id="@+id/complete_info_order"
        android:layout_width="match_parent"
        android:layout_height="@dimen/_40sdp"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        android:layout_marginLeft="@dimen/_20sdp"
        android:layout_marginTop="@dimen/_30sdp"
        android:layout_marginRight="@dimen/_20sdp"
        android:layout_marginBottom="@dimen/_60sdp"
        android:background="@drawable/login_button_frame"
        android:gravity="center"/>


</androidx.coordinatorlayout.widget.CoordinatorLayout>

我应该怎么做才能使按钮在循环视图中不移动??

非常感谢...

【问题讨论】:

    标签: android android-recyclerview android-coordinatorlayout


    【解决方案1】:

    试试这个:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <android.support.v7.widget.RecyclerView
            android:id="@+id/shopsList"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    
        <Button
            android:id="@+id/complete_info_order"
            android:text="Button"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_width="wrap_content"
            android:layout_height="40dp"/>
    
    </RelativeLayout>
    

    【讨论】:

    • 但我希望该按钮位于回收视图项目上,但位于底部..这意味着我希望回收视图位于按钮后面..因为我使用坐标布局
    • 您希望 Button 与 RecyclerView 重叠吗?好的,请参阅上面的编辑。 CoordinatorLayouts 真正用于协调 View 之间的移动,这不是你想要的。
    猜你喜欢
    • 1970-01-01
    • 2014-02-23
    • 1970-01-01
    • 1970-01-01
    • 2016-12-27
    • 1970-01-01
    • 1970-01-01
    • 2016-10-07
    • 1970-01-01
    相关资源
    最近更新 更多