将滚动条显示为完整视图,并在其中包含回收站视图 [英] Giving scroll to full view with recycler view inside it

查看:85
本文介绍了将滚动条显示为完整视图,并在其中包含回收站视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加一个屏幕,在该屏幕的顶部和底部都有一个这样的回收站视图:

I want to implment a screen where i have a layout on the top and below that i have a recycler view like this :

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    tools:context="com.app.InstHomeDir.Fragments.PendingDocument"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/main_bg"
   >

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginBottom="15dp"
        >

    <android.support.v7.widget.CardView

        android:background="@color/white"
        app:cardElevation="2dp"
        app:cardCornerRadius="2dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <com.app.InstHomeDir.Util.Roboto_Edit_Text_Bold
             android:textColor="@color/bl2d2d2d"
             android:padding="5dp"
            android:text="DOCUMENT LIST"
                android:textSize="20sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
            <com.app.InstHomeDir.Util.Roboto_EditText
             android:padding="5dp"
             android:textColor="#6f6f6f"
            android:layout_marginTop="5dp"
            android:layout_width="wrap_content"
                android:textSize="12sp"
            android:text="@string/Pending_Doc"
            android:layout_height="wrap_content"/>
        </LinearLayout>


    </android.support.v7.widget.CardView>


    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_penddoc"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_anchor="@id/toolbar_layout"
        app:layout_anchorGravity="bottom|center"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        >

    </android.support.v7.widget.RecyclerView>


    </LinearLayout>



</RelativeLayout>

现在我希望为整个视图提供滚动视图,但是当我这样做时,屏幕的滚动并不平滑,因为屏幕上有两个滚动条,如何解决此问题?谁能帮我吗?

now i wish to give scroll view to the entire view, but when i do that the scrolling of the screen is no smooth, as there are two scrolls available on the screen, how do I solve this issue? Can anyone help me?

推荐答案

添加页眉和页脚是一种方法,但是我发现这样做更容易. 将整个视图放入滚动视图中.现在,这将使滚动速度变慢,并且看起来不会很好,因此使用此代码可克服此问题:

Adding a header and footer is a way, but I found an easier view to do it. Put the whole view inside a scroll view. now this will make the scrolling a bit slow and it wont look nice, so to overcome this use this code :

  layoutManager = new LinearLayoutManager(getActivity()){
        @Override
        public boolean canScrollVertically() {
            return false;
        }
    };

现在的问题是,当我将整个视图添加到滚动视图中时,同一视图中有2个滚动.所以我们面对这个问题.现在,如果我们删除其中之一的滚动属性,则它将再次正常运行. 因此,我们删除了回收站视图的滚动属性,因为它是子视图.

now the problem was that there are 2 scrolls in the same view when I add the whole view inside a scroll view. So we face this problem. Now if we remove scrolling property of one of them then it works smoothly again. So we remove the scrolling property of the recycler view since it is the child.

像魅力一样工作.

这篇关于将滚动条显示为完整视图,并在其中包含回收站视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆