Extended Android Tab Layout with animated indicators that have continuous feedback.

Overview

Dachshund Tab Layout

License: MIT

Logo

Introduction

Boosted Android Tab Layout with custom animated indicators including "Dachshund" animation inspired by this.

Sample

Available Animated Indicators

Indicator Example Custom behavior
DachshundIndicator
PointMoveIndicator setInterpolator(TimeInterpolator interpolator)
LineMoveIndicator setEdgeRadius(int edgeRadius)
PointFadeIndicator
LineFadeIndicator setEdgeRadius(int edgeRadius)

Installation

Step 1

Add the JitPack repository to your build file

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2

Add the dependency

	dependencies {
		compile 'com.github.Andy671:Dachshund-Tab-Layout:v0.3.3'
	}

Usage

DachshundTabLayout is a subclass of TabLayout, so usage is pretty similar. The most of the original methods should work without any problems. See sample and source code for more info.

Add DachshundTabLayout to xml (after the Toolbar in the AppBarLayout), if you have TabLayout simply replace it:

 <android.support.design.widget.AppBarLayout
 ...
	<android.support.v7.widget.Toolbar           
	.../>
	<com.kekstudio.dachshundtablayout.DachshundTabLayout
		android:id="@+id/tab_layout"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"/>

Setup it with a ViewPager:

	DachshundTabLayout tabLayout = (DachshundTabLayout) findViewById(R.id.tab_layout);
	tabLayout.setupWithViewPager(yourViewPager);

If you want to change animated indicator (see Available Animated Indicators):

	//AvailableAnimatedIndicator - change it with available animated indicator

	AvailableAnimatedIndicator indicator = new AvailableAnimatedIndicator(tabLayout);
	tabLayout.setAnimatedIndicator(indicator);

Center align

In v0.3.2 I've added ddCenterAlign parameter. You can use it when you want to center the tabs in scrollable tabMode. Working behavior from Stackoverflow question.

<com.kekstudio.dachshundtablayout.DachshundTabLayout
		...
		custom:tabMode="scrollable"
		custom:ddCenterAlign="true"/>

Creating custom AnimatedIndicator

If you want to create your own custom AnimatedIndicator - you can implement AnimatedIndicatorInterface and if you want to use animators - AnimatorUpdateListener (See JavaDoc of AnimatedIndicatorInterface for more info):

public class CustomIndicator implements AnimatedIndicatorInterface, ValueAnimator.AnimatorUpdateListener {

    private DachshundTabLayout dachshundTabLayout;

    public CustomIndicator(DachshundTabLayout dachshundTabLayout){
        this.dachshundTabLayout = dachshundTabLayout;

    	//here set-up your Animators, Paints etc.
    }

    @Override
    public void onAnimationUpdate(ValueAnimator animator) {
    	// when animator updates - invalidate your canvas, and draw what you want.
    }

    @Override
    public void setSelectedTabIndicatorColor(@ColorInt int color) {
        // customization of color
    }

    @Override
    public void setSelectedTabIndicatorHeight(int height) {
        // customization of height
    }

    @Override
    public void setIntValues(int startXLeft, int endXLeft,
                             int startXCenter, int endXCenter,
                             int startXRight, int endXRight){
        // X-positions of the target and current tabs
    }

    @Override
    public void setCurrentPlayTime(long currentPlayTime) {
        // current play time of the animation
    }

    @Override
    public void draw(Canvas canvas) {
        //Make your draw calls here
    }

    @Override
    public long getDuration() {
        return DEFAULT_DURATION;
    }
}

XML Attributes

Attribute Type Default
ddIndicatorHeight dimension 6dp
ddIndicatorColor color Color.WHITE
ddAnimatedIndicator enum [dachshund, pointMove, lineMove, pointFade, lineFade] dachshund

Contribution

  • Feel free to fork the repo, make pull requests or fix existing bug
  • Feel free to open issues if you find some bug or unexpected behaviour
Comments
  • Not possible to set a custom animated indicator or select default ones programatically.

    Not possible to set a custom animated indicator or select default ones programatically.

    To reproduce:

    1. Import dachsund to a new empty project
    2. Add a DachsundTabLayout to the bottom of the main activity view with the following xml <com.kekstudio.dachshundtablayout.DachshundTabLayout android:id="@+id/homeTabLayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintBottom_toBotomOf="parent" />
    3. In the MainActivity's onStart, onCreate or onResume call setAnimatedIndicator(new LineMoveIndicator(dachsundTabLayout))
    4. Run the app

    Expected: App uses LineMoveIndicator once it runs

    Actual: App uses the default DachshundIndicator

    Problem, the way I understand it: setupAnimatedIndicator should not overule an AnimatedIndicator set through setAnimatedIndicator.

    When animatedIndicator is set programatically by calling setAnimatedIndicator in the Android Activity's onCreate, onStart or onResume methods the setupAnimatedIndicator is still called afterwards and the programatically set indicator with either default or whatever was set through xml.

    A potential quick fix could be to add a CUSTOM flag for the animatedIndicatorType that could be both set from xml and would be automatically used once setAnimatedIndicator has been called.

    opened by Krad23 4
  • How to Use setEdgeRadius(int edgeRadius) to change Radius LineMoveIndicator?

    How to Use setEdgeRadius(int edgeRadius) to change Radius LineMoveIndicator?

    Hi, I didnt found help about to set edge radius of LineMoveIndicator to ZERO! i want it as a keen rectangle! where to use setEdgeRadius(int edgeRadius) ?

    opened by saeed74 1
  • Disable TabLayout On Click

    Disable TabLayout On Click

    I'm using the new class provided by the design library : TabLayout. And I want in specific cases that the one I'm using can't change tab anymore. I manage to disable swipe on its viewpager but I can't figure out how to disable the change of page by clicking on tabs. Thank's in advance.

    **In The Normal Tablayout with below code i can disable it **

    LinearLayout tabStrip = ((LinearLayout)mTabLayout.getChildAt(0)); for(int i = 0; i < tabStrip.getChildCount(); i++) { tabStrip.getChildAt(i).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); }

    But in This Library How Can I Do It ?

    opened by morteza-moradi 1
  • java.lang.NoSuchMethodErro

    java.lang.NoSuchMethodErro

    hello andy671 I use it with an error what is the solution error:

    Process: com.example.ganger.dmzjapp, PID: 24343
                                                                                java.lang.NoSuchMethodError: No super method setupWithViewPager(Landroid/support/v4/view/ViewPager;Z)V in class Landroid/support/design/widget/TabLayout; or its super classes (declaration of 'android.support.design.widget.TabLayout' appears in /data/data/com.example.ganger.dmzjapp/files/instant-run/dex/slice-com.android.support-design-23.3.0_885fe9c4b8444b33318faa2144462abf1840cd46-classes.dex)
                                                                                    at com.kekstudio.dachshundtablayout.DachshundTabLayout.setupWithViewPager(DachshundTabLayout.java:122)
                                                                                    at com.kekstudio.dachshundtablayout.DachshundTabLayout.setupWithViewPager(DachshundTabLayout.java:117)
                                                                                    at com.example.ganger.dmzjapp.MainActivity.onCreate(MainActivity.java:158)
                                                                                    at android.app.Activity.performCreate(Activity.java:6237)
                                                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                    at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                    at android.os.Looper.loop(Looper.java:148)
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    

    code:

     pageAdapter=new MyPageAdapter(getSupportFragmentManager(),titles,fs);
            viewPager.setAdapter(pageAdapter);
    
            dachshundTabLayout= (DachshundTabLayout) findViewById(R.id.tab_layout);
            dachshundTabLayout.setupWithViewPager(viewPager);
    
    opened by guxuanyu 1
  • Error in Using without Pager

    Error in Using without Pager

    How can i use this without pager.i tried to add tabs using addTab method and later tried using addOntabselected Listener but its showing an error.I am using below code to do so. Is there any other way of doing the same thing or is there something wrong with my code ?

    DachshundTabLayout navigationTabStrip = (DachshundTabLayout) view.findViewById(R.id.tablayout);
        navigationTabStrip.addTab(new TabLayout.Tab().setText("Pug"),1,true);
        navigationTabStrip.addTab(new TabLayout.Tab().setText("Bulldog"),2);
        navigationTabStrip.addTab(new TabLayout.Tab().setText("Beagle"),3);
    

    with a addontabselectedlistener

    navigationTabStrip.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                Toast.makeText(getContext(), tab.getText(), Toast.LENGTH_SHORT).show();
            }
    
            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
    
            }
    
            @Override
            public void onTabReselected(TabLayout.Tab tab) {
    
            }
        });
    

    its showing an error

    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setContentDescription(java.lang.CharSequence)' on a null object reference at com.google.android.material.tabs.TabLayout$Tab.setText(TabLayout.java:1846)

    opened by Rudra-n-khatri 1
  • Use it inside REcycler view

    Use it inside REcycler view

    Is it possible to use this inside Recycler view to get the same effect. I want to have the effect for my vertical recycler view to get this kind of effect. https://i.stack.imgur.com/Dx38z.gif https://raw.githubusercontent.com/ogaclejapan/SmartTabLayout/master/art/demo4.gif

    opened by Rudra-n-khatri 0
Owner
Andrii
Student from Kyiv, obsessed with computer science and music.
Andrii
Continuous speech recognition library for Android with options to use GoogleVoiceIme dialog and offline mode.

Android Speech Recognition This library lets you perform continuous voice recognition in your android app with options to either use Google Voice Ime

Maxwell Obi 75 May 21, 2022
Animated Loader or Animated Progress Dialog android code.

AnimatedLoadingIndicator LoadingIndicator This is a simple but effective animated Loading Indicator which can easily ready to use integrated few lines

Yash Agarwal 95 Nov 15, 2022
🦚 An expandable layout that shows a two-level layout with an indicator.

ExpandableLayout ?? An expandable layout that shows a two-level layout with an indicator. Including in your project Gradle Add below codes to your roo

Jaewoong Eum 716 Dec 25, 2022
[] Easily have blurred and transparent background effect on your Android views.

##[DEPRECATED] BlurBehind Easily have blurred and transparent background effect on your Android views. Before API level 14 there was a Window flag cal

Gokberk Ergun 516 Nov 25, 2022
Allows the easy creation of animated transition effects when the state of Android UI has changed

android-transition Android-Transition allows the easy creation of view transitions that reacts to user inputs. The library is designed to be general e

Kai 615 Nov 14, 2022
Android ImageViews animated by Ken Burns Effect

KenBurnsView Android library that provides an extension to ImageView that creates an immersive experience by animating its drawable using the Ken Burn

Flávio Faria 2.7k Jan 2, 2023
DuGuang 1k Dec 14, 2022
A simple animated step view for Android

StepView A simple animated step view for Android. Backward and forward animations is supported. Usage Add jcenter() to repositories block in your grad

Bogdan Kornev 833 Dec 30, 2022
Simple android library to present an animated ferris wheel

Ferris Wheel View Overview An Android Library used to implement an animated Ferris Wheel in android. API SDK 15+ Written in Kotlin Supports landscape

Igor Lashkov 318 Dec 7, 2022
How to improve the user experience using animated icons with vector drawables on Android

Android Animated Icons How to improve the user experience using animated icons with vector drawables on Android English version https://medium.com/@an

André Mion 116 Nov 25, 2022
Android animated recording view

AnimatedRecordingView Android animated recording view .中文版 Preview Gradle compile 'com.haozhang.libary:android-animated-recording-view:1.0' How to use

Hand Zhang 348 Nov 16, 2022
This a demo application with animated SVG animation of Smiley

Animated-Smiley-Rating Animated Customer feedback and rating UI ?? License Copyright 2021 Aiman Muzafar Licensed under the Apache License, Version 2.0

Aiman Muzafar 12 Aug 12, 2021
🍭🚀💗 Tutorials about animations with Animators, Animated Vector Drawables, Shared Transitions, and more

?????? Tutorials about animations with Animators, Animated Vector Drawables, Shared Transitions, and more

Smart Tool Factory 696 Dec 28, 2022
Animated-splash-screen - Animate your Splash Screen using Lottie files.

Animated Splash Screen This small project shows how you can add animation into your android projects or create beautiful looking Splash Screen or Laun

Aashish Ace 0 Jan 2, 2022
Backarrow-animation-example - Animate back arrow to close button in Compose using animated drawables

Animate Back Arrow to Close Icon in Compose This is a simple demo for animated v

Jose Mateo 3 Feb 17, 2022
Custom-view-animated-file-downloader - Custom Views, Animations, Broadcast Receivers, Notifications

Downloader App Custom views , Drawing with Canvas, Animations (with motionlayout

null 2 Jun 24, 2022
Animated LazyColumn/LazyRow

Animated LazyColumn/LazyRow POC of how you can animate LazyColumn/LazyRow insertions/deletions/moving Note, this is not production ready or a library,

Roudi Korkis Kanaan 33 Dec 24, 2022
A program that converts an SGF-file to an animated GIF a la Hayauchi Super Igo style.

sgf2gif A program that converts an SGF-file to an animated GIF. The animated GIF is highly inspired by the classic game Hayauchi Super Igo for NES. Us

null 12 Jul 6, 2022
With MVVM Architecture pattern using Android Architecture Components This is a sample app demonstrating Youtube player animation using constraint layout

Youtube UI/UX Animation This is a sample app demonstrating Youtube UX/UI animation using ConstraintLayout.It implements the Keyframe Animation feature

Burhanuddin Rashid 866 Dec 29, 2022