Dachshund-Tab-Layout


Source link: https://github.com/Andy671/Dachshund-Tab-Layout

Dachshund Tab Layout

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.1'  
}

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);

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

Buy me a cup of coffee

Bitcoin Wallet: 15BuUMAW2jUdStPVkoNPt85P8tJnAy5vD4

Resources

CountryCodePicker will help users to

  • Search and select Country
  • Get selected country's name,code,currency and dial code

Gradle build inspector, clarifies what's going on inside your Gradle build.

Android library monitoring hardware sensors with RxJava Observables.

Frutilla lets java software development teams describe the tests in plain text, and link them to the specifications.

Twidere is a powerful twitter client for Android 4.0+, which gives you a full Material experience and nearly complete (and even better) Twitter feature.

Base is a lightweight library that gives you a clean architecture foundation for your Android MVP's.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes