androidandroid-fragmentsandroid-recyclerviewandroidimageslider

Image Slider with recyclerview scrolling


I have a bit of a problem with the SliderView I created. The sliderview can not be scrolled at the same time as the recyclerview. I've tried adding ScrollView but it still seems to be still.

Here is the layout:

fragment_home.xml

<FrameLayout 
    <android.support.v4.widget.SwipeRefreshLayout
        <LinearLayout
        <RelativeLayout
            <RelativeLayout
                <FrameLayout
                    <com.mimdudin.carekkerje.Activities.SliderView
                </FrameLayout>
            <View />
            <LinearLayout
        </RelativeLayout>
        <android.support.v7.widget.RecyclerView
        </RelativeLayout>
        </LinearLayout>
    </android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>

How can I resolve this?


Solution

  • As I understand, your achievement is hiding, scrolling or collapsing your SliderView which is placed above your RecyclerView.

    You have different options here. Choose one of them and make some research, you can find lots of documentations and tutorials about them.

    1. Add your SliderView as an item of RecyclerView and add it to first position. (like a HeaderView used in ListView)
    2. Use CollapsingToolbarLayout and put your SliderView as a collapsable view when the RecyclerView scrolls to bottom and expands when you scroll to top.
    3. You can use CoordinatorLayout behaviors to hide and show your slider with animations according to RecyclerView scrolling statuses.
    4. Use NestedScrollView and put your SliderView and RecyclerView inside.(setting nestedScrollingEnabled true/false is the trick)