简体   繁体   English

如何在recyclerView的开始和结束处制作可滚动的空白

[英]How make scrollable whitespace on start and end of recyclerView

I would do put white space on top and on bottom of a recyclerView. 我会在recyclerView的顶部和底部放置空白。

in html/css for example i can make a scrollable parent-container with fixed height and insert a child-container with adaptable height and set paddingTop and paddingBottom of child-container. 例如在html / css中,我可以制作一个具有固定高度的可滚动父容器,并插入一个高度可调的子容器,并设置子容器的paddingTop和paddingBottom。

i tryed to repeat this system in layout.xml 我试图在layout.xml中重复此系统

    <ScrollView
        android:id="@+id/ScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/RecyclerView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="50dp"
            android:paddingBottom="35dp"
            android:clipChildren="false"
            android:nestedScrollingEnabled="false"
            tools:itemCount="10" />

    </ScrollView>

but i see the "wrap_content" adapt height ONLY if that is minor of "match_parent", as the View is scrollable(in theory) (or that is what i undestand). 但是我只看到“ wrap_content”适应高度,如果那是“ match_parent”的次要高度,因为视图是可滚动的(理论上)(或者这就是我无法理解的)。 But this break my system because i need the child-container is NOT scrollable. 但这破坏了我的系统,因为我需要子容器不可滚动。

if i set nestedScrollingEnabled="false" cuts the elements out of the viewport, if i set "true" the recycleView scrolls normally but the whitespaces stay fixed 如果设置为nestedScrollingEnabled="false" ,则将元素从视口中切出;如果设置为“ true”,则recycleView会正常滚动,但空格保持固定

exist another way to get what I want? 存在获得我想要的另一种方式?

attempted result 尝试结果

try to use this way by adding clipToPadding and set to false you can add white space in top and bottom 尝试通过添加clipToPadding并将其设置为false来使用这种方式,可以在顶部和底部添加空格

<android.support.v7.widget.RecyclerView
    android:id="@+id/list_data"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="@dimen/view_padding"
    android:paddingRight="@dimen/view_padding"
    android:clipToPadding="false"
    android:paddingBottom="90dp"
    android:paddingTop="90dp"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM