All Projects → sandrfx → MetalRecyclerPagerView

sandrfx / MetalRecyclerPagerView

Licence: Apache-2.0 license
RecyclerView implementation for Android which makes it look and feel like ViewPager with item margins support (mutliple views effect).

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to MetalRecyclerPagerView

Discretescrollview
A scrollable list of items that centers the current element and provides easy-to-use APIs for cool item animations.
Stars: ✭ 5,533 (+21180.77%)
Mutual labels:  recyclerview, swipe, viewpager
Collapsingrefresh
AppBarLayout+ViewPager+RecyclerView的刷新功能
Stars: ✭ 69 (+165.38%)
Mutual labels:  recyclerview, viewpager
Verticalviewpager
A vertical scroll ViewPager implementation. Use with scrollable views(ListView, ScrollView, RecyclerView).
Stars: ✭ 64 (+146.15%)
Mutual labels:  recyclerview, viewpager
Swipemenulayout
🔥一个零耦合的侧滑菜单,支持RecyclerView、ListView、GridView等不同条目布局,支持菜单在左或在右,可选滑动阻塞,是否禁用等功能
Stars: ✭ 120 (+361.54%)
Mutual labels:  recyclerview, swipe
Recyclerviewhelper
📃 [Android Library] Giving powers to RecyclerView
Stars: ✭ 643 (+2373.08%)
Mutual labels:  recyclerview, swipe
Gallerylayoutmanager
New way to implements ViewPager/Gallery in Android with RecycleView
Stars: ✭ 684 (+2530.77%)
Mutual labels:  recyclerview, viewpager
Banner
Android Viewpager rotation control, application guide page controls, support vertical, horizontal cycle scrolling, extended from view support animation, indicator extension and so on;Android viewpager轮播图控件、app引导页控件,支持垂直、水平循环滚动,扩展自viewpager 支持动画,指示器扩展等。
Stars: ✭ 96 (+269.23%)
Mutual labels:  recyclerview, viewpager
Scrollingpagerindicator
Pager indicator inspired by Instagram. Lightweight and easy to set up.
Stars: ✭ 419 (+1511.54%)
Mutual labels:  recyclerview, viewpager
Swipeablecards
Stars: ✭ 136 (+423.08%)
Mutual labels:  recyclerview, swipe
Placeholderview
This library provides advance views for lists and stacks. Some of the views are build on top of RecyclerView and others are written in their own. Annotations are compiled by annotation processor to generate bind classes. DOCS -->
Stars: ✭ 2,104 (+7992.31%)
Mutual labels:  recyclerview, swipe
Gridpagersnaphelper
A powerful tools to impl grid paging layout by RecyclerView
Stars: ✭ 228 (+776.92%)
Mutual labels:  recyclerview, viewpager
Overscroll Decor
Android: iOS-like over-scrolling effect applicable over almost all scrollable Android views.
Stars: ✭ 2,671 (+10173.08%)
Mutual labels:  recyclerview, viewpager
Android Advancedrecyclerview
RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)
Stars: ✭ 5,172 (+19792.31%)
Mutual labels:  recyclerview, swipe
Base Mvvm
App built to showcase basic Android View components like ViewPager, RecyclerView(homogeneous and heterogeneous items), NavigationDrawer, Animated Vector Drawables, Collapsing Toolbar Layout etc. housed in a MVVM architecture
Stars: ✭ 18 (-30.77%)
Mutual labels:  recyclerview, viewpager
Dragdropswiperecyclerview
Kotlin Android library that extends RecyclerView to support gestures like drag & drop and swipe, among others. It works with vertical, horizontal and grid lists.
Stars: ✭ 469 (+1703.85%)
Mutual labels:  recyclerview, swipe
Recyclerpager
Using RecyclerView and SnapHelper replace ViewPager
Stars: ✭ 73 (+180.77%)
Mutual labels:  recyclerview, viewpager
Corbind
Kotlin Coroutines binding APIs for Android UI widgets from the platform and support libraries
Stars: ✭ 357 (+1273.08%)
Mutual labels:  recyclerview, viewpager
Adapter
A quick adapter library for RecyclerView, GridView, ListView, ViewPager, Spinner
Stars: ✭ 376 (+1346.15%)
Mutual labels:  recyclerview, viewpager
Fullrecyclerview
This is a compilation of different kinds and actions in recyclerView
Stars: ✭ 127 (+388.46%)
Mutual labels:  recyclerview, swipe
Reswipecard
a light lib for swipe the cards implemented by RecyclerView
Stars: ✭ 230 (+784.62%)
Mutual labels:  recyclerview, swipe

MetalRecyclerPagerView

Heavy-heavy metal made RecyclerView look and feel like a ViewPager.

Additionally to the full charged power of RecyclerView you can setup margins for pager items to achieve the following effect:

Alt text

Let's rock!

1. Add MetalRecyclerPagerView into your layout

<com.sandrlab.widgets.MetalRecyclerViewPager
    android:id="@+id/viewPager"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:itemMargin="32dp"/>

Here you can set app:itemMargin attribute to add item margin: it affects left and right margins only.

2. Create pager item view layout

Add @+id/root_layout id for your root item layout. For example:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root_layout"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <!-- ... -->

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

</FrameLayout>

3. Create Adapter

3.1 Create your adapter as usual for RecyclerView but inherit it from a new MetalRecyclerViewPager.MetalAdapter.

3.2 As for ViewHolder - also inherit it from MetalRecyclerViewPager.MetalViewHolder and call super.onBindViewHolder(holder, position) within your onBindViewHolder implementation (don't forget to call it, item margins are not able to work properly without this thing).

public class YourCoolAdapter extends MetalRecyclerViewPager.MetalAdapter<YourCoolAdapter.YourCoolViewHolder> {

    public YourCoolAdapter(@NonNull DisplayMetrics metrics, @NonNull List<String> yourDataSource) {
        super(metrics);
        
        // ...
    }

    @Override
    public void onBindViewHolder(FullMetalViewHolder holder, int position) {
        // don't forget to call supper.onBindViewHolder!
        super.onBindViewHolder(holder, position);

        // ...
    }

    static class YourCoolViewHolder extends MetalRecyclerViewPager.MetalViewHolder {

        public FullMetalViewHolder(View itemView) {
            super(itemView);

            // ...
        }
    }

    // ...
}

4. Put it all together

To instantiate your adapter you will need to pass DisplayMetrics into it. No need to setup LayoutManager - it's already done within MetalRecyclerViewPager itself.

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        DisplayMetrics metrics = getDisplayMetrics();
        List<String> metalList = Arrays.asList("\\m/", "\\m/", "\\m/");
        MetalRecyclerViewPager.MetalAdapter fullMetalAdapter = new YourCoolAdapter(metrics, metalList);

        MetalRecyclerViewPager viewPager = (MetalRecyclerViewPager) findViewById(R.id.viewPager);
        viewPager.setAdapter(fullMetalAdapter);
    }

    private DisplayMetrics getDisplayMetrics() {
        Display display = getWindowManager().getDefaultDisplay();
        DisplayMetrics metrics = new DisplayMetrics();
        display.getMetrics(metrics);

        return metrics;
    }
}

Download

Simply copy MetalRecyclerViewPager.java along with attrs.xml and ids.xml into your project.

Full sample project

Find it here.

Known issues

As we have a recycler view here, it always takes focus: if you place MetalRecyclerViewPager into ScrollView Android will automatically scroll layout to MetalRecyclerViewPager. To avoid this behavior place MetalRecyclerViewPager into NestedScrollView and add android:focusableInTouchMode="true" to upper container:

<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:focusableInTouchMode="true"
        android:orientation="vertical">
        
        <!-- ... -->
        
        <com.sandrlab.widgets.MetalRecyclerViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:itemMargin="32dp"/> 
            
        <!-- ... -->
        
    </LinearLayout>

</android.support.v4.widget.NestedScrollView>

License

Copyright (C) 2017. Alexander Bilchuk

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].