Android片段在使用recyclerview时滚动所有元素

我正在开发一个android应用程序。我正在使用FragmentRecyclerView在我的屏幕上有SearchView,标题RecyclerView和一个Button我希望屏幕如下图所示。

在此处输入图片说明

但是它将滚动所有视图。底部的按钮位于recyclerview last元素的最后。我的布局代码如下所示。

layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    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"
        android:weightSum="1">

        <SearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.25"
            android:queryHint="Search Item" />

        <LinearLayout
            android:id="@+id/lItemsHeader"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="5dip"
            android:layout_marginRight="5dip"
            android:layout_marginTop="2dip"
            android:layout_weight="0.25"
            android:background="@color/title_background">

            <TextView
                android:id="@+id/item2"
                style="@style/ItemsHeader"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginLeft="3dip"
                android:width="0dip"
                android:text="@string/caption_item"
                android:textColor="@color/background1" />
        </LinearLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/my_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.25"
            android:scrollbars="vertical" />

        <LinearLayout
            androidrientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="60dp"
            android:layout_weight="0.25">

            <Button
                android:id="@+id/btn1"
                android:layout_width="75dp"
                android:layout_height="35dp"
                android:layout_marginBottom="2dp"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="10dp"
                android:layout_weight="1"
                android:background="@color/title_background"
                android:text="Save &amp; Close"
                android:textColor="#FFFFFF"
                android:textSize="@dimen/text_size_small" />
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>

如何解决问题?请帮我。

MJM

更新了xml

  <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

        <SearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_alignParentTop="true"
            android:layout_height="match_parent"
            android:queryHint="Search Item" />

        <LinearLayout
            android:id="@+id/lItemsHeader"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="5dip"
            android:layout_marginRight="5dip"
            android:layout_marginTop="2dip"
            android:layout_below="@+id/search_view"
            android:background="@color/title_background">


            <TextView
                android:id="@+id/item2"
                style="@style/ItemsHeader"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginLeft="3dip"

                android:width="0dip"
                android:text="@string/caption_item"
                android:textColor="@color/background1" />

        </LinearLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/my_recycler_view"
            android:layout_below="@+id/lItemsHeader"
            android:layout_width="match_parent"
            android:layout_above="@+id/linearFooter"
            android:layout_height="match_parent"
            android:scrollbars="vertical" />

        <LinearLayout
            android:id="@+id/linearFooter"
            androidrientation="horizontal"
             android:layout_alignParentBottom="true"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="60dp">

            <Button
                android:id="@+id/btn1"
                android:layout_width="75dp"
                android:layout_height="35dp"
                android:layout_marginBottom="2dp"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="10dp"
                android:layout_weight="1"
                android:background="@color/title_background"
                android:text="Save &amp; Close"
                android:textColor="#FFFFFF"
                android:textSize="@dimen/text_size_small" />

        </LinearLayout>


    </RelativeLayout>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

RecyclerView在滚动时创建并绑定所有ViewHolders

Android,滚动所有元素:ImageViews,Textviews和ListViews

Android 在具有远程数据获取的片段中使用 RecyclerView

Recyclerview使用活动或片段android中的按钮动作向上和向下按钮滚动

过度滚动时加载RecyclerView元素

Android:使用片段或更改活动中的所有视图

使用tablayout切换片段时重新创建所有片段

展开/折叠子元素时,Android RecyclerView滚动到顶部

在片段中更新RecyclerView时,使用scrollToPosition()

嵌套滚动视图中的Recyclerview加载所有数据,而不是在滚动时一一调用图像

Android:RecyclerView 的 ImageView 在滚动时被回收

Android MotionLayout在RecyclerView滚动时崩溃

Android:滚动包含recyclerView的子级时如何滚动parentView

Android关闭所有片段onBackPressed

使用Android中的ViewModel将数据与带有recyclerview的片段传递到另一个片段

如何在点击时使用Jquery定位所有元素

在ConstraintLayout中使用RecyclerView时,所有RecyclerView项都不可见

在中心处于“选中”状态时,如何使RecyclerView对齐到中心并能够滚动到所有项目?

如何为所有范围使用片段?

使用带有 recyclerview 的协调器布局时滚动口吃

如何将所有元素滚动到目标元素

NestedScrollView中的RecyclerView导致RecyclerView膨胀所有元素

如何通过使用SeleniumWebdriver和Python滚动查找网页上的所有元素

如何使用包和网格布局将可滚动框架中的所有元素水平居中

如何使用 JavaScript 从动态滚动列表中获取所有元素?

不滚动并显示所有项目的RecyclerView

如何使Recyclerview显示所有项目并且无法滚动

Recyclerview - 无需滚动即可加载所有项目

Angular:使用片段滚动锚点时出错