├── sample
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── activity_sample.xml
│ │ │ │ └── fragment_page.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── kekstudio
│ │ │ └── dachshundtablayoutsample
│ │ │ └── SampleActivity.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── kekstudio
│ │ │ └── dachshundtablayoutsample
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── kekstudio
│ │ └── dachshundtablayoutsample
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── dachshundtablayout
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ ├── strings.xml
│ │ │ │ └── attrs.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── kekstudio
│ │ │ └── dachshundtablayout
│ │ │ ├── indicators
│ │ │ ├── AnimatedIndicatorType.java
│ │ │ ├── AnimatedIndicatorInterface.java
│ │ │ ├── PointMoveIndicator.java
│ │ │ ├── PointFadeIndicator.java
│ │ │ ├── LineMoveIndicator.java
│ │ │ ├── LineFadeIndicator.java
│ │ │ └── DachshundIndicator.java
│ │ │ ├── HelperUtils.java
│ │ │ └── DachshundTabLayout.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── kekstudio
│ │ │ └── dachshundtablayout
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── kekstudio
│ │ └── dachshundtablayout
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── dachshund_logo.png
├── .idea
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── inspectionProfiles
│ ├── profiles_settings.xml
│ └── Project_Default.xml
├── libraries
│ ├── com_google_code_findbugs_jsr305_2_0_1_jar.xml
│ ├── junit_junit_4_12_jar.xml
│ ├── javax_inject_javax_inject_1_jar.xml
│ ├── android_arch_core_common_1_0_0_jar.xml
│ ├── com_squareup_javawriter_2_1_1_jar.xml
│ ├── org_hamcrest_hamcrest_core_1_3_jar.xml
│ ├── android_arch_lifecycle_common_1_0_3_jar.xml
│ ├── org_hamcrest_hamcrest_library_1_3_jar.xml
│ ├── org_hamcrest_hamcrest_integration_1_3_jar.xml
│ ├── javax_annotation_javax_annotation_api_1_2_jar.xml
│ ├── com_android_support_support_annotations_27_0_2_jar.xml
│ ├── android_arch_lifecycle_runtime_1_0_3.xml
│ ├── com_android_support_design_27_0_2.xml
│ ├── com_android_support_support_v4_27_0_2.xml
│ ├── com_android_support_appcompat_v7_27_0_2.xml
│ ├── com_android_support_support_compat_27_0_2.xml
│ ├── com_android_support_transition_27_0_2.xml
│ ├── com_android_support_support_core_ui_27_0_2.xml
│ ├── com_android_support_support_fragment_27_0_2.xml
│ ├── com_android_support_support_core_utils_27_0_2.xml
│ ├── com_android_support_recyclerview_v7_27_0_2.xml
│ ├── com_android_support_support_media_compat_27_0_2.xml
│ ├── com_android_support_support_vector_drawable_27_0_2.xml
│ ├── com_android_support_animated_vector_drawable_27_0_2.xml
│ ├── com_android_support_test_rules_0_5.xml
│ ├── com_android_support_test_runner_0_5.xml
│ ├── com_android_support_test_espresso_espresso_core_2_2_2.xml
│ ├── com_android_support_test_espresso_espresso_idling_resource_2_2_2.xml
│ └── com_android_support_test_exposed_instrumentation_api_publish_0_5.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
├── modules.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── LICENSE
├── gradlew.bat
├── gradlew
└── README.md
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/dachshundtablayout/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':dachshundtablayout'
2 |
--------------------------------------------------------------------------------
/dachshund_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Andy671/Dachshund-Tab-Layout/HEAD/dachshund_logo.png
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Andy671/Dachshund-Tab-Layout/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Dachshund Tab Layout
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Andy671/Dachshund-Tab-Layout/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Andy671/Dachshund-Tab-Layout/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Andy671/Dachshund-Tab-Layout/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Andy671/Dachshund-Tab-Layout/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Andy671/Dachshund-Tab-Layout/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #37474F
4 | #263238
5 | #00BCD4
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Dachshund Tab Layout
3 |
4 |
5 | Hello blank fragment
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/java/com/kekstudio/dachshundtablayout/indicators/AnimatedIndicatorType.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayout.indicators;
2 |
3 | /**
4 | * Created by Andy671
5 | */
6 |
7 | public enum AnimatedIndicatorType {
8 | DACHSHUND,
9 | POINT_MOVE,
10 | LINE_MOVE,
11 | POINT_FADE,
12 | LINE_FADE
13 | }
14 |
--------------------------------------------------------------------------------
/sample/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/.idea/libraries/com_google_code_findbugs_jsr305_2_0_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/junit_junit_4_12_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/test/java/com/kekstudio/dachshundtablayout/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayout;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/sample/src/test/java/com/kekstudio/dachshundtablayoutsample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayoutsample;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #built application files
2 | *.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # generated files
12 | bin/
13 | gen/
14 |
15 | # Local configuration file (sdk path, etc)
16 | local.properties
17 |
18 | # Windows thumbnail db
19 | Thumbs.db
20 |
21 | # OSX files
22 | .DS_Store
23 |
24 | # Android Studio
25 | *.iml
26 | .idea
27 | .idea/libraries
28 | .idea/modules.xml
29 | .idea/workspace.xml
30 | .gradle
31 | build/
32 | .navigation
33 | captures/
34 | output.json
35 |
36 | #NDK
37 | obj/
38 | .externalNativeBuild
39 |
--------------------------------------------------------------------------------
/.idea/libraries/javax_inject_javax_inject_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/android_arch_core_common_1_0_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/com_squareup_javawriter_2_1_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/org_hamcrest_hamcrest_core_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/android_arch_lifecycle_common_1_0_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/org_hamcrest_hamcrest_library_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/org_hamcrest_hamcrest_integration_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/javax_annotation_javax_annotation_api_1_2_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/java/com/kekstudio/dachshundtablayout/HelperUtils.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayout;
2 |
3 | import android.content.res.Resources;
4 | import android.util.TypedValue;
5 |
6 | /**
7 | * Created by Andy671
8 | */
9 |
10 | public class HelperUtils {
11 |
12 | public static int pxToDp(float px) {
13 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, px, Resources.getSystem().getDisplayMetrics());
14 | }
15 |
16 | public static int dpToPx(int dp) {
17 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, Resources.getSystem().getDisplayMetrics());
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_support_annotations_27_0_2_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/android_arch_lifecycle_runtime_1_0_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_design_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_support_v4_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_appcompat_v7_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_support_compat_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_transition_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_support_core_ui_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/Andy/cocos2dx/android-sdk-macosx/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_support_fragment_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/dachshundtablayout/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/Andy/cocos2dx/android-sdk-macosx/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_support_core_utils_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_recyclerview_v7_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_support_media_compat_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_support_vector_drawable_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_animated_vector_drawable_27_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_test_rules_0_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_test_runner_0_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_test_espresso_espresso_core_2_2_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/sample/src/androidTest/java/com/kekstudio/dachshundtablayoutsample/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayoutsample;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.kekstudio.dachshundtablayout", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/androidTest/java/com/kekstudio/dachshundtablayout/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayout;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.kekstudio.dachshundtablayout.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_test_espresso_espresso_idling_resource_2_2_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dachshundtablayout/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 27
5 | buildToolsVersion "27.0.3"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 27
10 | versionCode 4
11 | versionName "0.3.3"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
27 | exclude group: 'com.android.support', module: 'support-annotations'
28 | })
29 | compile 'com.android.support:appcompat-v7:27.1.1'
30 | compile 'com.android.support:design:27.1.1'
31 |
32 | testCompile 'junit:junit:4.12'
33 | }
34 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_test_exposed_instrumentation_api_publish_0_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 | buildToolsVersion "27.0.3"
6 | defaultConfig {
7 | applicationId "com.kekstudio.dachshundtablayoutsample"
8 | minSdkVersion 15
9 | targetSdkVersion 27
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile project(':dachshundtablayout')
28 |
29 | compile 'com.android.support:appcompat-v7:27.1.1'
30 | compile 'com.android.support:support-v4:27.1.1'
31 | testCompile 'junit:junit:4.12'
32 | }
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 |
4 | Copyright (c) 2017 Andrii
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
31 |
32 |
33 |
34 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_page.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
19 |
20 |
27 |
28 |
35 |
36 |
43 |
44 |
51 |
52 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/java/com/kekstudio/dachshundtablayout/indicators/AnimatedIndicatorInterface.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayout.indicators;
2 |
3 | import android.graphics.Canvas;
4 | import android.support.annotation.ColorInt;
5 |
6 | /**
7 | * The interface you should implement for creating custom AnimatedIndicators.
8 | *
9 | * Created by Andy671
10 | */
11 |
12 | public interface AnimatedIndicatorInterface {
13 |
14 | /**
15 | * Default duration of the animation. Pass it to getDuration().
16 | */
17 | long DEFAULT_DURATION = 500;
18 |
19 | /**
20 | * *Can be called from DachshundTabLayout. Sets color of the indicator.
21 | *
22 | * @param color - color of the tab indicator.
23 | */
24 | void setSelectedTabIndicatorColor(@ColorInt int color);
25 |
26 |
27 | /**
28 | * *Can be called from DachshundTabLayout. Sets height of the indicator.
29 | *
30 | * @param height - height of the tab indicator.
31 | */
32 | void setSelectedTabIndicatorHeight(int height);
33 |
34 | /**
35 | * Updates values when swiping of the ViewPager starts.
36 | *
37 | * @param startXLeft X-coordinate of the current tab left edge
38 | *
39 | * @param endXLeft X-coordinate edge of the finish destination tab left edge
40 | *
41 | * @param startXCenter X-coordinate of the current tab center
42 | *
43 | * @param endXCenter X-coordinate of the finish destination tab center
44 | *
45 | * @param startXRight X-coordinate of the current tab right edge
46 | *
47 | * @param endXRight X-coordinate edge of the finish destination tab right edge
48 | *
49 | */
50 | void setIntValues(int startXLeft, int endXLeft,
51 | int startXCenter, int endXCenter,
52 | int startXRight, int endXRight);
53 |
54 | /**
55 | * Updates currentPlayTime when swiping of the ViewPager occurs.
56 | * (e.g. if we are on half of the way // currentPlayTime == getDuration() / 2 )
57 | *
58 | * You can use it in your animators (don't forget to Override getDuration() method)
59 | *
60 | * @param currentPlayTime swiping position in playTime.
61 | */
62 | void setCurrentPlayTime(long currentPlayTime);
63 |
64 | /**
65 | * Make your drawing calls here.
66 | * Call invalidate() when you need to redraw.
67 | *
68 | * @param canvas DachshundTabLayout canvas.
69 | */
70 | void draw(Canvas canvas);
71 |
72 | /**
73 | * Override it, if you want to work with animators, to make setCurrentPlayTime method work.
74 | *
75 | * @return the duration of your animator. Currently supporting only DEFAULT_DURATION.
76 | */
77 | long getDuration();
78 | }
79 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/java/com/kekstudio/dachshundtablayout/indicators/PointMoveIndicator.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayout.indicators;
2 |
3 | import android.animation.TimeInterpolator;
4 | import android.animation.ValueAnimator;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.graphics.Rect;
8 | import android.support.annotation.ColorInt;
9 | import android.view.animation.LinearInterpolator;
10 |
11 | import com.kekstudio.dachshundtablayout.DachshundTabLayout;
12 |
13 | /**
14 | * Created by Andy671
15 | */
16 |
17 | public class PointMoveIndicator implements AnimatedIndicatorInterface, ValueAnimator.AnimatorUpdateListener{
18 |
19 | private Paint paint;
20 | private Rect rect;
21 |
22 | private int height;
23 |
24 | private ValueAnimator valueAnimator;
25 |
26 | private DachshundTabLayout dachshundTabLayout;
27 |
28 | private int frameX;
29 |
30 | public PointMoveIndicator(DachshundTabLayout dachshundTabLayout) {
31 | this.dachshundTabLayout = dachshundTabLayout;
32 |
33 | valueAnimator = new ValueAnimator();
34 | valueAnimator.setInterpolator(new LinearInterpolator());
35 | valueAnimator.setDuration(DEFAULT_DURATION);
36 | valueAnimator.addUpdateListener(this);
37 |
38 | paint = new Paint();
39 | paint.setAntiAlias(true);
40 | paint.setStyle(Paint.Style.FILL);
41 |
42 | rect = new Rect();
43 |
44 | frameX = (int) dachshundTabLayout.getChildXCenter(dachshundTabLayout.getCurrentPosition());
45 | }
46 |
47 | public void setInterpolator(TimeInterpolator interpolator){
48 | valueAnimator.setInterpolator(interpolator);
49 | }
50 |
51 | @Override
52 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
53 | frameX = (int) valueAnimator.getAnimatedValue();
54 |
55 | rect.left = frameX - height / 2;
56 | rect.right = frameX + height / 2;
57 | rect.top = dachshundTabLayout.getHeight() - height;
58 | rect.bottom = dachshundTabLayout.getHeight();
59 |
60 | dachshundTabLayout.invalidate(rect);
61 | }
62 |
63 | @Override
64 | public void setSelectedTabIndicatorColor(@ColorInt int color) {
65 | paint.setColor(color);
66 | }
67 |
68 | @Override
69 | public void setSelectedTabIndicatorHeight(int height) {
70 | this.height = height;
71 | }
72 |
73 | @Override
74 | public void setIntValues(int startXLeft, int endXLeft,
75 | int startXCenter, int endXCenter,
76 | int startXRight, int endXRight) {
77 | valueAnimator.setIntValues(startXCenter, endXCenter);
78 | }
79 |
80 | @Override
81 | public void setCurrentPlayTime(long currentPlayTime) {
82 | valueAnimator.setCurrentPlayTime(currentPlayTime);
83 | }
84 |
85 | @Override
86 | public void draw(Canvas canvas) {
87 | canvas.drawCircle(frameX, canvas.getHeight() - height/2, height/2, paint);
88 | }
89 |
90 | @Override
91 | public long getDuration() {
92 | return valueAnimator.getDuration();
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/java/com/kekstudio/dachshundtablayout/indicators/PointFadeIndicator.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayout.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.support.annotation.ColorInt;
8 | import android.view.animation.LinearInterpolator;
9 |
10 | import com.kekstudio.dachshundtablayout.DachshundTabLayout;
11 |
12 | /**
13 | * Created by Andy671
14 | */
15 |
16 | public class PointFadeIndicator implements AnimatedIndicatorInterface, ValueAnimator.AnimatorUpdateListener {
17 | private Paint paint;
18 |
19 | private int height;
20 |
21 | private ValueAnimator valueAnimator;
22 |
23 | private DachshundTabLayout dachshundTabLayout;
24 |
25 | private int startX, endX;
26 |
27 | private int originColor, startColor, endColor;
28 |
29 | public PointFadeIndicator(DachshundTabLayout dachshundTabLayout) {
30 | this.dachshundTabLayout = dachshundTabLayout;
31 |
32 | valueAnimator = new ValueAnimator();
33 | valueAnimator.setInterpolator(new LinearInterpolator());
34 | valueAnimator.setDuration(DEFAULT_DURATION);
35 | valueAnimator.addUpdateListener(this);
36 | valueAnimator.setIntValues(0,255);
37 |
38 | paint = new Paint();
39 | paint.setAntiAlias(true);
40 | paint.setStyle(Paint.Style.FILL);
41 |
42 | startX = (int) dachshundTabLayout.getChildXCenter(dachshundTabLayout.getCurrentPosition());
43 | }
44 |
45 | @Override
46 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
47 | int startAlpha = 255 - (int) valueAnimator.getAnimatedValue();
48 | startColor = Color.argb(startAlpha, Color.red(originColor), Color.green(originColor), Color.blue(originColor) );
49 |
50 | int endAlpha = (int) valueAnimator.getAnimatedValue();
51 | endColor = Color.argb(endAlpha, Color.red(originColor), Color.green(originColor), Color.blue(originColor) );
52 |
53 | dachshundTabLayout.invalidate();
54 | }
55 |
56 | @Override
57 | public void setSelectedTabIndicatorColor(@ColorInt int color) {
58 | this.originColor = color;
59 | startColor = color;
60 | endColor = Color.TRANSPARENT;
61 | }
62 |
63 | @Override
64 | public void setSelectedTabIndicatorHeight(int height) {
65 | this.height = height;
66 | }
67 |
68 | @Override
69 | public void setIntValues(int startXLeft, int endXLeft,
70 | int startXCenter, int endXCenter,
71 | int startXRight, int endXRight) {
72 | startX = startXCenter;
73 | endX = endXCenter;
74 | }
75 |
76 | @Override
77 | public void setCurrentPlayTime(long currentPlayTime) {
78 | valueAnimator.setCurrentPlayTime(currentPlayTime);
79 | }
80 |
81 | @Override
82 | public void draw(Canvas canvas) {
83 | paint.setColor(startColor);
84 | canvas.drawCircle(startX, canvas.getHeight() - height/2, height/2, paint);
85 |
86 | paint.setColor(endColor);
87 | canvas.drawCircle(endX, canvas.getHeight() - height/2, height/2, paint);
88 | }
89 |
90 | @Override
91 | public long getDuration() {
92 | return valueAnimator.getDuration();
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/kekstudio/dachshundtablayoutsample/SampleActivity.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayoutsample;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentStatePagerAdapter;
7 | import android.support.v4.view.ViewPager;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.Toolbar;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.animation.AccelerateInterpolator;
14 |
15 | import com.kekstudio.dachshundtablayout.DachshundTabLayout;
16 | import com.kekstudio.dachshundtablayout.HelperUtils;
17 | import com.kekstudio.dachshundtablayout.indicators.DachshundIndicator;
18 | import com.kekstudio.dachshundtablayout.indicators.LineFadeIndicator;
19 | import com.kekstudio.dachshundtablayout.indicators.LineMoveIndicator;
20 | import com.kekstudio.dachshundtablayout.indicators.PointFadeIndicator;
21 | import com.kekstudio.dachshundtablayout.indicators.PointMoveIndicator;
22 |
23 |
24 | public class SampleActivity extends AppCompatActivity {
25 |
26 | private static final String DOG_BREEDS[] = {"Pug", "Beagle", "Bulldog", "Poodle"};
27 |
28 | private ViewPager viewPager;
29 | private DachshundTabLayout tabLayout;
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_sample);
35 |
36 | setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
37 |
38 | viewPager = findViewById(R.id.view_pager);
39 | viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager()));
40 |
41 | tabLayout = findViewById(R.id.tab_layout);
42 | tabLayout.setupWithViewPager(viewPager);
43 | }
44 |
45 | public void onClickDachshund(View view){
46 | tabLayout.setAnimatedIndicator(new DachshundIndicator(tabLayout));
47 | }
48 |
49 | public void onClickPointMove(View view){
50 | tabLayout.setAnimatedIndicator(new PointMoveIndicator(tabLayout));
51 | }
52 |
53 | public void onClickPointMoveAccelerate(View view){
54 | PointMoveIndicator pointMoveIndicator = new PointMoveIndicator(tabLayout);
55 | pointMoveIndicator.setInterpolator(new AccelerateInterpolator());
56 | tabLayout.setAnimatedIndicator(pointMoveIndicator);
57 | }
58 |
59 | public void onClickLineMove(View view){
60 | tabLayout.setAnimatedIndicator(new LineMoveIndicator(tabLayout));
61 | }
62 |
63 | public void onClickPointFade(View view){
64 | tabLayout.setAnimatedIndicator(new PointFadeIndicator(tabLayout));
65 | }
66 |
67 | public void onClickLineFade(View view){
68 | LineFadeIndicator lineFadeIndicator = new LineFadeIndicator(tabLayout);
69 | tabLayout.setAnimatedIndicator(lineFadeIndicator);
70 |
71 | lineFadeIndicator.setSelectedTabIndicatorHeight(HelperUtils.dpToPx(2));
72 | lineFadeIndicator.setEdgeRadius(0);
73 | }
74 |
75 | public class PagerAdapter extends FragmentStatePagerAdapter {
76 | public PagerAdapter(FragmentManager fm) {
77 | super(fm);
78 | }
79 |
80 | @Override
81 | public Fragment getItem(int i) {
82 | return new PageFragment();
83 | }
84 |
85 | @Override
86 | public int getCount() {
87 | return DOG_BREEDS.length;
88 | }
89 |
90 | @Override
91 | public CharSequence getPageTitle(int position) {
92 | return DOG_BREEDS[position];
93 | }
94 | }
95 |
96 | public static class PageFragment extends Fragment {
97 |
98 | public PageFragment() {
99 | }
100 |
101 | @Override
102 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
103 | Bundle savedInstanceState) {
104 | return inflater.inflate(R.layout.fragment_page, container, false);
105 | }
106 | }
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/java/com/kekstudio/dachshundtablayout/indicators/LineMoveIndicator.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayout.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Rect;
7 | import android.graphics.RectF;
8 | import android.support.annotation.ColorInt;
9 | import android.view.animation.LinearInterpolator;
10 |
11 | import com.kekstudio.dachshundtablayout.DachshundTabLayout;
12 |
13 | /**
14 | * Created by Andy671
15 | */
16 |
17 | public class LineMoveIndicator implements AnimatedIndicatorInterface, ValueAnimator.AnimatorUpdateListener {
18 |
19 | private Paint paint;
20 | private RectF rectF;
21 | private Rect rect;
22 |
23 | private int height;
24 | private int edgeRadius;
25 | private int leftX, rightX;
26 |
27 | private ValueAnimator valueAnimatorLeft, valueAnimatorRight;
28 |
29 | private LinearInterpolator linearInterpolator;
30 |
31 | private DachshundTabLayout dachshundTabLayout;
32 |
33 | public LineMoveIndicator(DachshundTabLayout dachshundTabLayout){
34 | this.dachshundTabLayout = dachshundTabLayout;
35 |
36 | linearInterpolator = new LinearInterpolator();
37 |
38 | valueAnimatorLeft = new ValueAnimator();
39 | valueAnimatorLeft.setDuration(DEFAULT_DURATION);
40 | valueAnimatorLeft.addUpdateListener(this);
41 | valueAnimatorLeft.setInterpolator(linearInterpolator);
42 |
43 | valueAnimatorRight = new ValueAnimator();
44 | valueAnimatorRight.setDuration(DEFAULT_DURATION);
45 | valueAnimatorRight.addUpdateListener(this);
46 | valueAnimatorRight.setInterpolator(linearInterpolator);
47 |
48 | rectF = new RectF();
49 | rect = new Rect();
50 |
51 | paint = new Paint();
52 | paint.setAntiAlias(true);
53 | paint.setStyle(Paint.Style.FILL);
54 |
55 | leftX = (int) dachshundTabLayout.getChildXLeft(dachshundTabLayout.getCurrentPosition());
56 | rightX = (int) dachshundTabLayout.getChildXRight(dachshundTabLayout.getCurrentPosition());
57 |
58 | edgeRadius = -1;
59 | }
60 |
61 | public void setEdgeRadius(int edgeRadius){
62 | this.edgeRadius = edgeRadius;
63 |
64 | dachshundTabLayout.invalidate();
65 | }
66 |
67 | @Override
68 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
69 | leftX = (int) valueAnimatorLeft.getAnimatedValue();
70 | rightX = (int) valueAnimatorRight.getAnimatedValue();
71 |
72 | rect.top = dachshundTabLayout.getHeight() - height;
73 | rect.left = leftX + height/2;
74 | rect.right = rightX - height/2;
75 | rect.bottom = dachshundTabLayout.getHeight();
76 |
77 | dachshundTabLayout.invalidate(rect);
78 | }
79 |
80 | @Override
81 | public void setSelectedTabIndicatorColor(@ColorInt int color) {
82 | paint.setColor(color);
83 | }
84 |
85 | @Override
86 | public void setSelectedTabIndicatorHeight(int height) {
87 | this.height = height;
88 |
89 | if(edgeRadius == -1)
90 | edgeRadius = height;
91 | }
92 |
93 | @Override
94 | public void setIntValues(int startXLeft, int endXLeft,
95 | int startXCenter, int endXCenter,
96 | int startXRight, int endXRight){
97 | valueAnimatorLeft.setIntValues(startXLeft, endXLeft);
98 | valueAnimatorRight.setIntValues(startXRight, endXRight);
99 | }
100 |
101 | @Override
102 | public void setCurrentPlayTime(long currentPlayTime) {
103 | valueAnimatorLeft.setCurrentPlayTime(currentPlayTime);
104 | valueAnimatorRight.setCurrentPlayTime(currentPlayTime);
105 | }
106 |
107 | @Override
108 | public void draw(Canvas canvas) {
109 | rectF.top = dachshundTabLayout.getHeight() - height;
110 | rectF.left = leftX + height/2;
111 | rectF.right = rightX - height/2;
112 | rectF.bottom = dachshundTabLayout.getHeight();
113 |
114 | canvas.drawRoundRect(rectF, edgeRadius, edgeRadius, paint);
115 | }
116 |
117 | @Override
118 | public long getDuration() {
119 | return valueAnimatorLeft.getDuration();
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/java/com/kekstudio/dachshundtablayout/indicators/LineFadeIndicator.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayout.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.RectF;
8 | import android.support.annotation.ColorInt;
9 | import android.view.animation.LinearInterpolator;
10 |
11 | import com.kekstudio.dachshundtablayout.DachshundTabLayout;
12 |
13 | /**
14 | * Created by Andy671
15 | */
16 |
17 | public class LineFadeIndicator implements AnimatedIndicatorInterface, ValueAnimator.AnimatorUpdateListener {
18 | private Paint paint;
19 | private RectF rectF;
20 |
21 | private int height;
22 | private int edgeRadius;
23 |
24 | private ValueAnimator valueAnimator;
25 |
26 | private DachshundTabLayout dachshundTabLayout;
27 |
28 | private int startXLeft, startXRight, endXLeft, endXRight;
29 |
30 | private int originColor, startColor, endColor;
31 |
32 | public LineFadeIndicator(DachshundTabLayout dachshundTabLayout) {
33 | this.dachshundTabLayout = dachshundTabLayout;
34 |
35 | valueAnimator = new ValueAnimator();
36 | valueAnimator.setInterpolator(new LinearInterpolator());
37 | valueAnimator.setDuration(DEFAULT_DURATION);
38 | valueAnimator.addUpdateListener(this);
39 | valueAnimator.setIntValues(0,255);
40 |
41 | paint = new Paint();
42 | paint.setAntiAlias(true);
43 | paint.setStyle(Paint.Style.FILL);
44 |
45 | rectF = new RectF();
46 |
47 | startXLeft = (int) dachshundTabLayout.getChildXLeft(dachshundTabLayout.getCurrentPosition());
48 | startXRight = (int) dachshundTabLayout.getChildXRight(dachshundTabLayout.getCurrentPosition());
49 |
50 | edgeRadius = -1;
51 | }
52 |
53 | public void setEdgeRadius(int edgeRadius){
54 | this.edgeRadius = edgeRadius;
55 |
56 | dachshundTabLayout.invalidate();
57 | }
58 |
59 | @Override
60 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
61 | int startAlpha = 255 - (int) valueAnimator.getAnimatedValue();
62 | startColor = Color.argb(startAlpha, Color.red(originColor), Color.green(originColor), Color.blue(originColor) );
63 |
64 | int endAlpha = (int) valueAnimator.getAnimatedValue();
65 | endColor = Color.argb(endAlpha, Color.red(originColor), Color.green(originColor), Color.blue(originColor) );
66 |
67 | dachshundTabLayout.invalidate();
68 | }
69 |
70 | @Override
71 | public void setSelectedTabIndicatorColor(@ColorInt int color) {
72 | this.originColor = color;
73 | startColor = color;
74 | endColor = Color.TRANSPARENT;
75 | }
76 |
77 | @Override
78 | public void setSelectedTabIndicatorHeight(int height) {
79 | this.height = height;
80 |
81 | if(edgeRadius == -1)
82 | edgeRadius = height;
83 | }
84 |
85 | @Override
86 | public void setIntValues(int startXLeft, int endXLeft,
87 | int startXCenter, int endXCenter,
88 | int startXRight, int endXRight) {
89 | this.startXLeft = startXLeft;
90 | this.startXRight = startXRight;
91 | this.endXLeft = endXLeft;
92 | this.endXRight = endXRight;
93 | }
94 |
95 | @Override
96 | public void setCurrentPlayTime(long currentPlayTime) {
97 | valueAnimator.setCurrentPlayTime(currentPlayTime);
98 | }
99 |
100 | @Override
101 | public void draw(Canvas canvas) {
102 | rectF.left = startXLeft + height/2;
103 | rectF.right = startXRight - height/2;
104 | rectF.top = dachshundTabLayout.getHeight() - height;
105 | rectF.bottom = dachshundTabLayout.getHeight();
106 |
107 | paint.setColor(startColor);
108 | canvas.drawRoundRect(rectF, edgeRadius, edgeRadius, paint);
109 |
110 | rectF.left = endXLeft + height/2;
111 | rectF.right = endXRight - height/2;
112 |
113 | paint.setColor(endColor);
114 | canvas.drawRoundRect(rectF, edgeRadius, edgeRadius, paint);
115 | }
116 |
117 | @Override
118 | public long getDuration() {
119 | return valueAnimator.getDuration();
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/java/com/kekstudio/dachshundtablayout/indicators/DachshundIndicator.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayout.indicators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Rect;
7 | import android.graphics.RectF;
8 | import android.support.annotation.ColorInt;
9 | import android.view.animation.AccelerateInterpolator;
10 | import android.view.animation.DecelerateInterpolator;
11 |
12 | import com.kekstudio.dachshundtablayout.DachshundTabLayout;
13 |
14 | /**
15 | * Created by Andy671
16 | */
17 |
18 | public class DachshundIndicator implements AnimatedIndicatorInterface, ValueAnimator.AnimatorUpdateListener {
19 |
20 | private Paint paint;
21 | private RectF rectF;
22 | private Rect rect;
23 |
24 | private int height;
25 |
26 | private ValueAnimator valueAnimatorLeft, valueAnimatorRight;
27 |
28 | private DachshundTabLayout dachshundTabLayout;
29 |
30 | private AccelerateInterpolator accelerateInterpolator;
31 | private DecelerateInterpolator decelerateInterpolator;
32 |
33 | private int leftX, rightX;
34 |
35 | public DachshundIndicator(DachshundTabLayout dachshundTabLayout){
36 | this.dachshundTabLayout = dachshundTabLayout;
37 |
38 | valueAnimatorLeft = new ValueAnimator();
39 | valueAnimatorLeft.setDuration(DEFAULT_DURATION);
40 | valueAnimatorLeft.addUpdateListener(this);
41 |
42 | valueAnimatorRight = new ValueAnimator();
43 | valueAnimatorRight.setDuration(DEFAULT_DURATION);
44 | valueAnimatorRight.addUpdateListener(this);
45 |
46 | accelerateInterpolator = new AccelerateInterpolator();
47 | decelerateInterpolator = new DecelerateInterpolator();
48 |
49 | rectF = new RectF();
50 | rect = new Rect();
51 |
52 | paint = new Paint();
53 | paint.setAntiAlias(true);
54 | paint.setStyle(Paint.Style.FILL);
55 |
56 | leftX = (int) dachshundTabLayout.getChildXCenter(dachshundTabLayout.getCurrentPosition());
57 | rightX = leftX;
58 | }
59 |
60 | @Override
61 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
62 | leftX = (int) valueAnimatorLeft.getAnimatedValue();
63 | rightX = (int) valueAnimatorRight.getAnimatedValue();
64 |
65 | rect.top = dachshundTabLayout.getHeight() - height;
66 | rect.left = leftX - height/2;
67 | rect.right = rightX + height/2;
68 | rect.bottom = dachshundTabLayout.getHeight();
69 |
70 | dachshundTabLayout.invalidate(rect);
71 | }
72 |
73 | @Override
74 | public void setSelectedTabIndicatorColor(@ColorInt int color) {
75 | paint.setColor(color);
76 | }
77 |
78 | @Override
79 | public void setSelectedTabIndicatorHeight(int height) {
80 | this.height = height;
81 | }
82 |
83 | @Override
84 | public void setIntValues(int startXLeft, int endXLeft,
85 | int startXCenter, int endXCenter,
86 | int startXRight, int endXRight) {
87 | boolean toRight = endXCenter - startXCenter >= 0;
88 |
89 | if(toRight){
90 | valueAnimatorLeft.setInterpolator(accelerateInterpolator);
91 | valueAnimatorRight.setInterpolator(decelerateInterpolator);
92 | }else{
93 | valueAnimatorLeft.setInterpolator(decelerateInterpolator);
94 | valueAnimatorRight.setInterpolator(accelerateInterpolator);
95 | }
96 |
97 | valueAnimatorLeft.setIntValues(startXCenter, endXCenter);
98 | valueAnimatorRight.setIntValues(startXCenter, endXCenter);
99 | }
100 |
101 | @Override
102 | public void setCurrentPlayTime(long currentPlayTime) {
103 | valueAnimatorLeft.setCurrentPlayTime(currentPlayTime);
104 | valueAnimatorRight.setCurrentPlayTime(currentPlayTime);
105 | }
106 |
107 | @Override
108 | public void draw(Canvas canvas) {
109 | rectF.top = dachshundTabLayout.getHeight() - height;
110 | rectF.left = leftX - height/2;
111 | rectF.right = rightX + height/2;
112 | rectF.bottom = dachshundTabLayout.getHeight();
113 |
114 | canvas.drawRoundRect(rectF, height, height, paint);
115 | }
116 |
117 | @Override
118 | public long getDuration() {
119 | return valueAnimatorLeft.getDuration();
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Dachshund Tab Layout
2 | [](https://developer.android.com/training/basics/supporting-devices/platforms.html)
3 | [](https://jitpack.io/#Andy671/Dachshund-Tab-Layout)
4 | [](https://opensource.org/licenses/MIT)
5 |
6 | # 
7 |
8 | ## Introduction
9 | Boosted Android Tab Layout with custom animated indicators including "Dachshund" animation inspired by [this](https://material.uplabs.com/posts/tab-interaction).
10 |
11 | ## Sample
12 | 
13 |
14 | ## Available Animated Indicators
15 | | Indicator | Example | Custom behavior |
16 | |--------------------- |--------------------------------| ----- |
17 | | DachshundIndicator |  | |
18 | | PointMoveIndicator | | setInterpolator(TimeInterpolator interpolator) |
19 | | LineMoveIndicator |  | setEdgeRadius(int edgeRadius)|
20 | | PointFadeIndicator |  | |
21 | | LineFadeIndicator |  | setEdgeRadius(int edgeRadius)|
22 |
23 | ###
24 |
25 | ## Installation
26 |
27 | ### Step 1
28 | Add the JitPack repository to your build file
29 | ```gradle
30 | allprojects {
31 | repositories {
32 | ...
33 | maven { url 'https://jitpack.io' }
34 | }
35 | }
36 | ```
37 |
38 | ### Step 2
39 | Add the dependency
40 | ```gradle
41 | dependencies {
42 | compile 'com.github.Andy671:Dachshund-Tab-Layout:v0.3.3'
43 | }
44 | ```
45 |
46 | # Usage
47 | 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.
48 |
49 | Add DachshundTabLayout to xml (after the Toolbar in the AppBarLayout), if you have TabLayout simply replace it:
50 | ```xml
51 |
55 |
59 | ```
60 |
61 | Setup it with a ViewPager:
62 | ```java
63 | DachshundTabLayout tabLayout = (DachshundTabLayout) findViewById(R.id.tab_layout);
64 | tabLayout.setupWithViewPager(yourViewPager);
65 | ```
66 |
67 | If you want to change animated indicator (see **Available Animated Indicators**):
68 | ```java
69 | //AvailableAnimatedIndicator - change it with available animated indicator
70 |
71 | AvailableAnimatedIndicator indicator = new AvailableAnimatedIndicator(tabLayout);
72 | tabLayout.setAnimatedIndicator(indicator);
73 | ```
74 |
75 | ## Center align
76 | In **v0.3.2** I've added **ddCenterAlign** parameter. You can use it when you want to center the tabs in **scrollable** tabMode.
77 | Working behavior from [Stackoverflow](https://stackoverflow.com/questions/33191794/android-tablayout-with-active-tab-always-at-center-just-like-in-play-newsstand) question.
78 | ```xml
79 |
83 | ```
84 |
85 | ## Creating custom AnimatedIndicator
86 | 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):
87 | ```java
88 | public class CustomIndicator implements AnimatedIndicatorInterface, ValueAnimator.AnimatorUpdateListener {
89 |
90 | private DachshundTabLayout dachshundTabLayout;
91 |
92 | public CustomIndicator(DachshundTabLayout dachshundTabLayout){
93 | this.dachshundTabLayout = dachshundTabLayout;
94 |
95 | //here set-up your Animators, Paints etc.
96 | }
97 |
98 | @Override
99 | public void onAnimationUpdate(ValueAnimator animator) {
100 | // when animator updates - invalidate your canvas, and draw what you want.
101 | }
102 |
103 | @Override
104 | public void setSelectedTabIndicatorColor(@ColorInt int color) {
105 | // customization of color
106 | }
107 |
108 | @Override
109 | public void setSelectedTabIndicatorHeight(int height) {
110 | // customization of height
111 | }
112 |
113 | @Override
114 | public void setIntValues(int startXLeft, int endXLeft,
115 | int startXCenter, int endXCenter,
116 | int startXRight, int endXRight){
117 | // X-positions of the target and current tabs
118 | }
119 |
120 | @Override
121 | public void setCurrentPlayTime(long currentPlayTime) {
122 | // current play time of the animation
123 | }
124 |
125 | @Override
126 | public void draw(Canvas canvas) {
127 | //Make your draw calls here
128 | }
129 |
130 | @Override
131 | public long getDuration() {
132 | return DEFAULT_DURATION;
133 | }
134 | }
135 | ```
136 |
137 |
138 | ## XML Attributes
139 | | Attribute | Type | Default |
140 | | ----------------------|:-------------------:| :-----------|
141 | | ddIndicatorHeight | dimension | 6dp |
142 | | ddIndicatorColor | color | Color.WHITE |
143 | | ddAnimatedIndicator | enum [dachshund, pointMove, lineMove, pointFade, lineFade] | dachshund |
144 |
145 | ## Contribution
146 | - Feel free to fork the repo, make pull requests or fix existing bug
147 | - Feel free to open issues if you find some bug or unexpected behaviour
148 |
149 |
--------------------------------------------------------------------------------
/dachshundtablayout/src/main/java/com/kekstudio/dachshundtablayout/DachshundTabLayout.java:
--------------------------------------------------------------------------------
1 | package com.kekstudio.dachshundtablayout;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.support.annotation.ColorInt;
8 | import android.support.annotation.Nullable;
9 | import android.support.design.widget.TabLayout;
10 | import android.support.v4.view.ViewCompat;
11 | import android.support.v4.view.ViewPager;
12 | import android.util.AttributeSet;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.widget.LinearLayout;
16 |
17 | import com.kekstudio.dachshundtablayout.indicators.AnimatedIndicatorInterface;
18 | import com.kekstudio.dachshundtablayout.indicators.AnimatedIndicatorType;
19 | import com.kekstudio.dachshundtablayout.indicators.DachshundIndicator;
20 | import com.kekstudio.dachshundtablayout.indicators.LineFadeIndicator;
21 | import com.kekstudio.dachshundtablayout.indicators.LineMoveIndicator;
22 | import com.kekstudio.dachshundtablayout.indicators.PointFadeIndicator;
23 | import com.kekstudio.dachshundtablayout.indicators.PointMoveIndicator;
24 |
25 | /**
26 | * Created by Andy671
27 | */
28 |
29 | public class DachshundTabLayout extends TabLayout implements ViewPager.OnPageChangeListener {
30 |
31 | private static final int DEFAULT_HEIGHT_DP = 6;
32 |
33 | private int mIndicatorColor;
34 | private int mIndicatorHeight;
35 |
36 | private int mCurrentPosition;
37 |
38 | private boolean mCenterAlign;
39 |
40 | private LinearLayout mTabStrip;
41 |
42 | private AnimatedIndicatorType mAnimatedIndicatorType;
43 | private AnimatedIndicatorInterface mAnimatedIndicator;
44 |
45 | private int mTempPosition, mTempPositionOffsetPixels;
46 | private float mTempPositionOffset;
47 |
48 | public DachshundTabLayout(Context context) {
49 | this(context, null);
50 | }
51 |
52 | public DachshundTabLayout(Context context, AttributeSet attrs) {
53 | this(context, attrs, 0);
54 | }
55 |
56 | public DachshundTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
57 | super(context, attrs, defStyleAttr);
58 |
59 | super.setSelectedTabIndicatorHeight(0);
60 |
61 | mTabStrip = (LinearLayout) super.getChildAt(0);
62 |
63 | TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DachshundTabLayout);
64 |
65 | this.mIndicatorHeight = ta.getDimensionPixelSize(R.styleable.DachshundTabLayout_ddIndicatorHeight, HelperUtils.dpToPx(DEFAULT_HEIGHT_DP));
66 | this.mIndicatorColor = ta.getColor(R.styleable.DachshundTabLayout_ddIndicatorColor, Color.WHITE);
67 | this.mCenterAlign = ta.getBoolean(R.styleable.DachshundTabLayout_ddCenterAlign, false);
68 | this.mAnimatedIndicatorType = AnimatedIndicatorType.values()[ta.getInt(R.styleable.DachshundTabLayout_ddAnimatedIndicator, 0)];
69 |
70 | ta.recycle();
71 | }
72 |
73 | @Override
74 | protected void onLayout(boolean changed, int l, int t, int r, int b) {
75 | super.onLayout(changed, l, t, r, b);
76 |
77 | if (mCenterAlign) {
78 | View firstTab = ((ViewGroup) getChildAt(0)).getChildAt(0);
79 | View lastTab = ((ViewGroup) getChildAt(0)).getChildAt(((ViewGroup) getChildAt(0)).getChildCount() - 1);
80 | ViewCompat.setPaddingRelative(getChildAt(0),
81 | (getWidth() / 2) - (firstTab.getWidth() / 2),
82 | 0,
83 | (getWidth() / 2) - (lastTab.getWidth() / 2),
84 | 0);
85 | }
86 |
87 | if (mAnimatedIndicator == null) {
88 | setupAnimatedIndicator();
89 | }
90 |
91 | onPageScrolled(mTempPosition, mTempPositionOffset, mTempPositionOffsetPixels);
92 | }
93 |
94 | private void setupAnimatedIndicator() {
95 | switch (mAnimatedIndicatorType) {
96 | case DACHSHUND:
97 | setAnimatedIndicator(new DachshundIndicator(this));
98 | break;
99 | case POINT_MOVE:
100 | setAnimatedIndicator(new PointMoveIndicator(this));
101 | break;
102 | case LINE_MOVE:
103 | setAnimatedIndicator(new LineMoveIndicator(this));
104 | break;
105 | case POINT_FADE:
106 | setAnimatedIndicator(new PointFadeIndicator(this));
107 | break;
108 | case LINE_FADE:
109 | setAnimatedIndicator(new LineFadeIndicator(this));
110 | break;
111 | }
112 | }
113 |
114 | public void setAnimatedIndicator(AnimatedIndicatorInterface animatedIndicator) {
115 | this.mAnimatedIndicator = animatedIndicator;
116 |
117 | animatedIndicator.setSelectedTabIndicatorColor(mIndicatorColor);
118 | animatedIndicator.setSelectedTabIndicatorHeight(mIndicatorHeight);
119 |
120 | invalidate();
121 | }
122 |
123 | @Override
124 | public void setSelectedTabIndicatorColor(@ColorInt int color) {
125 | this.mIndicatorColor = color;
126 | if (mAnimatedIndicator != null) {
127 | mAnimatedIndicator.setSelectedTabIndicatorColor(color);
128 |
129 | invalidate();
130 | }
131 | }
132 |
133 | @Override
134 | public void setSelectedTabIndicatorHeight(int height) {
135 | this.mIndicatorHeight = height;
136 | if (mAnimatedIndicator != null) {
137 | mAnimatedIndicator.setSelectedTabIndicatorHeight(height);
138 |
139 | invalidate();
140 | }
141 |
142 | }
143 |
144 | public void setCenterAlign(boolean centerAlign) {
145 | this.mCenterAlign = centerAlign;
146 |
147 | requestLayout();
148 | }
149 |
150 | @Override
151 | public void setupWithViewPager(@Nullable ViewPager viewPager) {
152 | this.setupWithViewPager(viewPager, true);
153 | }
154 |
155 | @Override
156 | public void setupWithViewPager(@Nullable final ViewPager viewPager, boolean autoRefresh) {
157 | super.setupWithViewPager(viewPager, autoRefresh);
158 |
159 | //TODO
160 | if (viewPager != null) {
161 | viewPager.removeOnPageChangeListener(this);
162 | viewPager.addOnPageChangeListener(this);
163 | }
164 | }
165 |
166 | @Override
167 | public void draw(Canvas canvas) {
168 | super.draw(canvas);
169 |
170 | if (mAnimatedIndicator != null)
171 | mAnimatedIndicator.draw(canvas);
172 |
173 | }
174 |
175 | @Override
176 | public void onPageScrollStateChanged(final int state) {
177 | }
178 |
179 | @Override
180 | public void onPageScrolled(final int position, final float positionOffset,
181 | final int positionOffsetPixels) {
182 | this.mTempPosition = position;
183 | this.mTempPositionOffset = positionOffset;
184 | this.mTempPositionOffsetPixels = positionOffsetPixels;
185 |
186 | if ((position > mCurrentPosition) || (position + 1 < mCurrentPosition)) {
187 | mCurrentPosition = position;
188 | }
189 |
190 | int mStartXLeft, mStartXCenter, mStartXRight, mEndXLeft, mEndXCenter, mEndXRight;
191 |
192 | if (position != mCurrentPosition) {
193 |
194 | mStartXLeft = (int) getChildXLeft(mCurrentPosition);
195 | mStartXCenter = (int) getChildXCenter(mCurrentPosition);
196 | mStartXRight = (int) getChildXRight(mCurrentPosition);
197 |
198 | mEndXLeft = (int) getChildXLeft(position);
199 | mEndXRight = (int) getChildXRight(position);
200 | mEndXCenter = (int) getChildXCenter(position);
201 |
202 | if (mAnimatedIndicator != null) {
203 | mAnimatedIndicator.setIntValues(mStartXLeft, mEndXLeft,
204 | mStartXCenter, mEndXCenter,
205 | mStartXRight, mEndXRight);
206 | mAnimatedIndicator.setCurrentPlayTime((long) ((1 - positionOffset) * (int) mAnimatedIndicator.getDuration()));
207 | }
208 |
209 | } else {
210 |
211 | mStartXLeft = (int) getChildXLeft(mCurrentPosition);
212 | mStartXCenter = (int) getChildXCenter(mCurrentPosition);
213 | mStartXRight = (int) getChildXRight(mCurrentPosition);
214 |
215 | if (mTabStrip.getChildAt(position + 1) != null) {
216 |
217 | mEndXLeft = (int) getChildXLeft(position + 1);
218 | mEndXCenter = (int) getChildXCenter(position + 1);
219 | mEndXRight = (int) getChildXRight(position + 1);
220 |
221 | } else {
222 | mEndXLeft = (int) getChildXLeft(position);
223 | mEndXCenter = (int) getChildXCenter(position);
224 | mEndXRight = (int) getChildXRight(position);
225 | }
226 |
227 | if (mAnimatedIndicator != null) {
228 | mAnimatedIndicator.setIntValues(mStartXLeft, mEndXLeft,
229 | mStartXCenter, mEndXCenter,
230 | mStartXRight, mEndXRight);
231 | mAnimatedIndicator.setCurrentPlayTime((long) (positionOffset * (int) mAnimatedIndicator.getDuration()));
232 | }
233 |
234 | }
235 |
236 | if (positionOffset == 0) {
237 | mCurrentPosition = position;
238 | }
239 |
240 | }
241 |
242 | @Override
243 | public void onPageSelected(final int position) {
244 | }
245 |
246 | public int getCurrentPosition() {
247 | return mCurrentPosition;
248 | }
249 |
250 | public float getChildXLeft(int position) {
251 | View tab = mTabStrip.getChildAt(position);
252 | if (tab != null)
253 | return tab.getX();
254 | else
255 | return 0;
256 | }
257 |
258 | public float getChildXCenter(int position) {
259 | View tab = mTabStrip.getChildAt(position);
260 | if (tab != null) {
261 | int width = tab.getWidth() == 0 ? tab.getMeasuredWidth() : tab.getWidth();
262 | return tab.getX() + width / 2;
263 | } else
264 | return 0;
265 | }
266 |
267 | public float getChildXRight(int position) {
268 | View tab = mTabStrip.getChildAt(position);
269 | if (tab != null) {
270 | int width = tab.getWidth() == 0 ? tab.getMeasuredWidth() : tab.getWidth();
271 | return tab.getX() + width;
272 | } else
273 | return 0;
274 | }
275 |
276 | public AnimatedIndicatorInterface getAnimatedIndicator() {
277 | return mAnimatedIndicator;
278 | }
279 |
280 |
281 | }
282 |
--------------------------------------------------------------------------------