A beautiful leanback port for Smartphones and Tablets

Overview

MaterialLeanBack

A beautiful leanback port for Smartphones and Tablets

Android app on Google Play

screen

Sample

Android app on Google Play

gif

Usage

In your layout

<com.github.florent37.materialleanback.MaterialLeanBack
        android:id="@+id/materialLeanBack"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        app:mlb_background="@color/background"
        app:mlb_lineSpacing="30dp"

        app:mlb_paddingBottom="30dp"
        app:mlb_paddingLeft="30dp"
        app:mlb_paddingRight="30dp"
        app:mlb_paddingTop="40dp"

        app:mlb_titleColor="@android:color/white" />

And in your activity/fragment

materialLeanBack.setAdapter(new MaterialLeanBack.Adapter<TestViewHolder>() {
            @Override
            public int getLineCount() {
                return 10;
            }

            @Override
            public int getCellsCount(int line) {
                return 10;
            }

            @Override
            public TestViewHolder onCreateViewHolder(ViewGroup viewGroup, int line) {
                View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.cell_test, viewGroup, false);
                return new TestViewHolder(view);
            }

            @Override
            public void onBindViewHolder(TestViewHolder viewHolder, int i) {
                viewHolder.textView.setText("test " + i);

                String url = "http://www.lorempixel.com/40" + viewHolder.row + "/40" + viewHolder.cell + "/";
                Picasso.with(viewHolder.imageView.getContext()).load(url).into(viewHolder.imageView);
            }

            @Override
            public String getTitleForRow(int row) {
                return "Line " + row;
            }
            
            @Override
            public int getEnlargedItemPosition(int position) {

                Toast.makeText(MainActivity.this,String.valueOf(position),Toast.LENGTH_LONG).show();

                return super.getEnlargedItemPosition(position);
            }

        });

Available attributes

<com.github.florent37.materialleanback.MaterialLeanBack
        android:id="@+id/materialLeanBack"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        app:mlb_lineSpacing="30dp"

        app:mlb_paddingTop="40dp"
        app:mlb_paddingBottom="30dp"
        app:mlb_paddingLeft="30dp"
        app:mlb_paddingRight="30dp"

        app:mlb_background="@color/background"
        app:mlb_backgroundOverlay="0.5"
        app:mlb_backgroundOverlayColor="#333"

        app:mlb_titleColor="@android:color/white"
        app:mlb_titleSize="15sp"

        app:mlb_overlapCards="true"
        app:mlb_animateCards="true"
        app:mlb_cardElevationEnlarged="10"
        app:mlb_cardElevationReduced="5"
        />

Add custom views

materialLeanBack.setAdapter(new MaterialLeanBack.Adapter<TestViewHolder>() {

    ...usual methods...

    public RecyclerView.ViewHolder getCustomViewForRow(ViewGroup viewgroup, int row) {
        if (row == 3) {
            View view = LayoutInflater.from(viewgroup.getContext()).inflate(R.layout.header, viewgroup, false);
            return new RecyclerView.ViewHolder(view) {
            };
        } else
            return null;
    }

    @Override
    public boolean isCustomView(int row) {
        return row == 3;
    }

    @Override
    public void onBindCustomView(RecyclerView.ViewHolder viewHolder, int row) {
        super.onBindCustomView(viewHolder, row);
    }
}

Download

Buy Me a Coffee at ko-fi.com

In your module Download

compile 'com.github.florent37:materialleanback:1.0.2'

compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.nineoldandroids:library:2.4.0'

Credits

Author: Florent Champigny

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2015 florent37, Inc.

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.
Comments
  • wrong row count

    wrong row count

    when trying to return one or tow rows it returns nothing yet if i returned 3 rows it returns 1 row only if i returned 4 rows it returns 2 rows it returns the rows count - 2 same for the cell count it returns the count - 2

    opened by a3adel 4
  • OnItemClickListener to get row & column no.

    OnItemClickListener to get row & column no.

    Hi florent37,

    Thanks for this awesome library but I'm having an issue with implementing the item click listener for this view. I have tried modifying the adapter but with that I am only being able to fetch either row no or column no at once. Without the click functionality it only looks like a gallery.

    opened by therahulmeena 3
  • Last Item in a row doesn't get hovered

    Last Item in a row doesn't get hovered

    When scrolling through a row with multiple items the last card doesn't get hovered. As because the first one does, I'm assuming actually the last one should do so, too.

    Can you please take a look at it @florent37 ?

    opened by PDDStudio 1
  • Line title

    Line title

    putting line value to null or change it's color to transparent are solutions to disable title, but it will be more useful if we get a property to enable or disable title for the line .

    opened by arbelkilani 1
  • Improper implementation

    Improper implementation

    The cells and lines that appear are two less than what was declared in MaterialLeanBack.Adapter.getCellsCount() and MaterialLeanBack.Adapter.getLineCount()

    opened by edwinkr2000 1
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 0
  • Data binding

    Data binding

    hello, i wanted to do something like nested recyclerview and then i found this library. I am creating an android application based on this project.

    but i m stuck at this :

    String url = "http://www.lorempixel.com/40" + viewHolder.row + "/40" + viewHolder.cell + "/";
    Picasso.with(viewHolder.imageView.getContext()).load(url).into(viewHolder.imageView);

    how can i bind arrays of images in this?

    listImages1["path1", "path2", "path3", "path4"] listImages2["samplePath1", "samplePath2", "samplePath3", "samplePath4"] listImages3["tempPath5", "tempPath6", "tempPath7", "tempPath8"]

    A little help will solve my issue... :)

    opened by krunalgandhijksol 0
  • Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference

    Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference

    • Followed every step but still getting this exception
    Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
    
    E/AndroidRuntime( 5763): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
    E/AndroidRuntime( 5763):    at com.github.florent37.materialleanback.line.LineAdapter.onCreateViewHolder(LineAdapter.java:53)
    E/AndroidRuntime( 5763):    at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5779)
    E/AndroidRuntime( 5763):    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5003)
    E/AndroidRuntime( 5763):    at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4913)
    E/AndroidRuntime( 5763):    at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029)
    E/AndroidRuntime( 5763):    at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1414)
    E/AndroidRuntime( 5763):    at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377)
    E/AndroidRuntime( 5763):    at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578)
    E/AndroidRuntime( 5763):    at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3260)
    E/AndroidRuntime( 5763):    at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3069)
    E/AndroidRuntime( 5763):    at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3518)
    
    opened by LeBronoMars 1
Owner
Florent CHAMPIGNY
Florent CHAMPIGNY
null 2.4k Dec 30, 2022
This component like SwipeRefreshLayout, it is more beautiful than SwipeRefreshLayout.

android-PullRefreshLayout This component like SwipeRefreshLayout, it is more beautiful than SwipeRefreshLayout. Demo Usage Add dependency. dependencie

星一 2.1k Dec 3, 2022
FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

null 33 Dec 8, 2022
TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.

This project isn't maintained anymore. It is now recommended to use https://github.com/peterLaurence/MapView. MapView is maintained by Peter, one of o

Mike Dunn 1.5k Nov 21, 2022
Implementation of ExpandableListview with custom header and custom content.

ExpandableLayout ExpandableLayout provides an easy way to create a view called header with an expandable view. Both view are external layout to allow

Robin Chutaux 1.6k Dec 12, 2022
[Archived] Highlight the best bits of your app to users quickly, simply, and cool...ly

ShowcaseView The ShowcaseView (SCV) library is designed to highlight and showcase specific parts of apps to the user with a distinctive and attractive

Alex Curran 5.6k Dec 16, 2022
This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.

Note: we are not actively responding to issues right now. If you find a bug, please submit a PR. Android Sliding Up Panel This library provides a simp

Umano: News Read To You 9.4k Dec 31, 2022
VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions.

Vorolay VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions. [Voronoi diagram] (https://en.wikip

Daniil Jurjev 918 Dec 4, 2022
Navigation Drawer Activity with material design style and simplified methods

MaterialNavigationDrawer Navigation Drawer Activity with material design style and simplified methods       It requires 10+ API and android support v7

Fabio Biola 1.6k Dec 30, 2022
Android Sample Project with Material Design and Toolbar.

AndroidMaterialDesignToolbar -- PROJECT IS NOT SUPPORTED Android Sample Project with Material Design and Toolbar. Project use Appcompat library for ma

kemal selim tekinarslan 713 Nov 11, 2022
Easy, flexible and powerful Swipe Layout for Android

SwipeRevealLayout A layout that you can swipe/slide to show another layout. Demo Overview Drag mode Drag mode normal: Drag mode same_level: Features F

Chau Thai 1.5k Jan 4, 2023
Android LinearLayout with drag and drop to reorder.

DragLinearLayout An Android LinearLayout that supports draggable and swappable child Views. Why? Why bother doing drag & swap in a LinearLayout when t

Justas Medeišis 446 Nov 25, 2022
A layout that hide the header when the body is scrolled down and reveal it when the header is scrolled up

AndroidAutoHideHeader A layout that hide the header when the body is scrolled down and reveal it when the header is scrolled up Demo Import it ! In yo

Vadim Caen 48 Apr 22, 2022
You don’t want your apps look and feel boring, do you? Add some bubbles!

#BubbleAnimationLayout Say hello to Bubble Animation Layout for Android by Cleveroad You don’t want your apps look and feel boring, do you? Add some b

Cleveroad 576 Nov 23, 2022
BlurView - A very fast and dynamic blur layout for Android

BlurView - A very fast and dynamic blur layout for Android

null 16 Jul 11, 2022
This assignment gives you basically a post list and its detail with comments.🚀

Android Assignment ?? Description This assignment gives you basically a post list and its detail with comments. ?? Features Users can see random post

Okan AYDIN 31 Dec 20, 2022
A Playground repository to showcase UI's and transitions built using Motion Layout.

A collection of UI's built to showcase the capabilities of Motion Layout and Constraint Layout 2.0/2.1

Saurabh 163 Dec 22, 2022
Added support to modify text size and indicator width based on the original TabLayout.

XTabLayout——可修改选中项字体大小和指示器长度的TabLayout XTabLayout是基于design包中的TabLayout进行了功能的扩展,在保留原有功能的基础上,增加了修改选中项字体大小、修改指示器长度以及限制屏幕显示范围内显示的Tab个数。 集成步骤: 1.添加XTabLayo

Kennor 660 Dec 20, 2022
ConstraintLayout is an Android layout component which allows you to position and size widgets in a flexible way

ConstraintLayout is a layout manager for Android which allows you to position and size widgets in a flexible way. It's available for both the Android view system and Jetpack Compose.

Android Jetpack 970 Jan 6, 2023