Custom Tabs with Material Design effects

Overview

MaterialTabs

Custom Tabs with Material Design animations for pre-Lollipop devices
Android Arsenal     Donate

Download example apk

It requires 14+ API and android support v7 (Toolbar)

IMPORTANT NOTICE

This library is no longer supported.
I have not enough time to continue developing at this time and the android design support library implements the tabs features in the better way, so I think it is useless now. If anyone wants to keep alive this library they can send pull requests AFTER testing the code and exmplaining what they have changed and why. Thanks to all contributors

Dependency: Android-UI Reveal Color View
If you are using MaterialTabs in your app and would like to be listed here, please let me know via email!

How to use:

define it in xml layout with custom attributes ```xml ``` ( I'm working on use wrap_content instead 48dp)

Connect to java code and add to viewPager

MaterialTabHost tabHost;

@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		tabHost = (MaterialTabHost) this.findViewById(R.id.materialTabHost);
		pager = (ViewPager) this.findViewById(R.id.viewpager);
		
		// init view pager
		pagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
		pager.setAdapter(pagerAdapter);
		pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
            	// when user do a swipe the selected tab change
                tabHost.setSelectedNavigationItem(position);
            }
        });
		
		// insert all tabs from pagerAdapter data
		for (int i = 0; i < pagerAdapter.getCount(); i++) {
            tabHost.addTab(
                    tabHost.newTab() 
                            .setIcon(getIcon(i))
                            .setTabListener(this)
                            );
    }
}

@Override
	public void onTabSelected(MaterialTab tab) {
		// when the tab is clicked the pager swipe content to the tab position
		pager.setCurrentItem(tab.getPosition());
		
	}

N.B. Your activity must extends ActionBarActivity implements MaterialTabListener

How to import

Android Studio

Add this to your build.gradle:

dependencies {
    compile 'it.neokree:MaterialTabs:0.11'
}

Limitations

Actually, this library have some limitations: - No selector animations

These problems are currently in development

Fixed and Scrollable tabs.

With text tabs

[1 - 3] Fixed Tabs
[4 - ∞] Scrollable Tabs

With icon tabs

[1 - 5] Fixed Tabs
[6 - ∞] Scrollable Tabs

screenshot

screenshot

screenshot

screenshot

You might also like...
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

Android drawer icon with material design animation
Android drawer icon with material design animation

LDrawer Android drawer icon with material design animation Note Basically same as appcompat_v7 version 21, you can use appcompat_v7 compile 'com.andro

[] Android Library that implements Snackbars from Google's Material Design documentation.
[] Android Library that implements Snackbars from Google's Material Design documentation.

DEPRECATED This lib is deprecated in favor of Google's Design Support Library which includes a Snackbar and is no longer being developed. Thanks for a

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

Android drawer icon with material design animation
Android drawer icon with material design animation

LDrawer Android drawer icon with material design animation Note Basically same as appcompat_v7 version 21, you can use appcompat_v7 compile 'com.andro

Floating Action Button for Android based on Material Design specification
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

Material Design ProgressBar with consistent appearance
Material Design ProgressBar with consistent appearance

MaterialProgressBar Material Design ProgressBar with consistent appearance on Android 4.0+. Why MaterialProgressBar? Consistent appearance on Android

Material Design RatingBar with better appearance
Material Design RatingBar with better appearance

MaterialRatingBar Material Design RatingBar with better appearance, compatible with Android 3.0+. Why MaterialRatingBar? Consistent appearance on Andr

A library support form with material design, construct same with Android UI Framework

SwingUI A slight Java Swing library support form with material design, construct same with Android UI Framework writen in Kotlin Supported: 1. Screen:

Comments
  • add some setters and getters to get icon of tab and change it programmatically

    add some setters and getters to get icon of tab and change it programmatically

    I needed to change a tab icon rec programmatically and i did it like this

    Drawable newicon; MaterialTabHost tabHost; ... tabHost.gettabon(3).setIcon(newicon);

    opened by m04az 0
  • Fixing sample project and switch to gradle dependencies

    Fixing sample project and switch to gradle dependencies

    Hi neokree, nice repo :+1: and helped me, but some code's error after cloned, now have been fixed and some changes added.

    • Added demo fragment
    • Deleted module and replaced by gradle dependencies

    hope will be easier to use

    opened by CreatorB 2
  • setTypeFace method for MaterialTab host

    setTypeFace method for MaterialTab host

    This helper methods can be very useful if you want to use font awesome icons as text for the tabs.

    Example:

    Typeface fontAwesome = Typeface.createFromAsset(getAssets(), "fonts/fontawesome-webfont.ttf");

        for (int i = 0; i < adapter.getCount(); i++) {
    
            MaterialTab tab = tabHost.newTab();
            tab.setText(adapter.getIcon(i));
            tab.setTabListener(this);
            tab.setTypeFace(fontAwesome);
            tabHost.addTab(tab);
    
    
        }
    
    opened by swaheed2 2
Owner
Fabio Biola
Fabio Biola
Default colors and dimens per Material Design guidelines and Android Design guidelines inside one library.

Material Design Dimens Default colors and dimens per Material Design guidelines and Android Design guidelines inside one library. Dimens Pattern: R.di

Dmitry Malkovich 1.4k Jan 3, 2023
A library to bring fully animated Material Design components to pre-Lolipop Android.

Material MaterialLibrary is an Open Source Android library that back-port Material Design components to pre-Lolipop Android. MaterialLibrary's origina

Rey Pham 6k Dec 21, 2022
Material Design icons by Google

Material design icons Material design icons is the official icon set from Google. The icons are designed under the material design guidelines. 4.0.0 U

Google 47.1k Jan 9, 2023
The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.

MaterialDrawer ... the flexible, easy to use, all in one drawer library for your Android project. What's included ?? • Setup ??️ • Migration Guide ??

Mike Penz 11.6k Dec 27, 2022
A Material Design ViewPager easy to use library

MaterialViewPager Material Design ViewPager easy to use library Sample And have a look on a sample Youtube Video : Youtube Link Download In your modul

Florent CHAMPIGNY 8.2k Jan 1, 2023
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

Zendesk 6.4k Dec 26, 2022
EditText in Material Design

MaterialEditText NOTE: 2.0 is NOT BACKWARDS COMPATIBLE! See more on wiki or 中文看这里 AppCompat v21 makes it easy to use Material Design EditText in our a

Kai Zhu 6.1k Dec 30, 2022
Implementation of Ripple effect from Material Design for Android API 9+

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

Robin Chutaux 4.9k Dec 30, 2022
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Carbon Material Design implementation for Android 4.0 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implemen

null 3k Jan 9, 2023
Material Design ProgressBar with consistent appearance

MaterialProgressBar Material Design ProgressBar with consistent appearance on Android 4.0+. Why MaterialProgressBar? Consistent appearance on Android

Hai Zhang 2.2k Dec 21, 2022