max max - 1 year ago 1259
Android Question

use RecyclerView like vertical viewpager

is this possible to use recyclerview like verticalpager .

what I want is when a user scrolls always the first item offset from the top be zero. like when you scroll in viewpager. is this possible?


Yes, you can.

You can use simple LinearLayoutManager:

recyclerView.setLayoutManager(new LinearLayoutManager(getContenxt(), LinearLayoutManager.HORIZONTAL));

and for RecyclerView.Adapter View item use layout_height="match_parent" to get View on full width of screen.

or just use this lib: RecyclerViewPager


recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
    public void onScrollStateChanged(int newState) {
        if(newState == RecyclerView.SCROLL_STATE_IDLE) {
            // special handler to avoid displaying half elements

    public void onScrolled(int dx, int dy) {