├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── drawable-hdpi │ │ │ ├── ic_date.png │ │ │ ├── ic_home.png │ │ │ ├── ic_wifi.png │ │ │ ├── ic_heart.png │ │ │ ├── ic_bookmark.png │ │ │ └── ic_assignment.png │ │ ├── drawable-mdpi │ │ │ ├── ic_date.png │ │ │ ├── ic_home.png │ │ │ ├── ic_wifi.png │ │ │ ├── ic_heart.png │ │ │ ├── ic_bookmark.png │ │ │ └── ic_assignment.png │ │ ├── drawable-xhdpi │ │ │ ├── ic_date.png │ │ │ ├── ic_heart.png │ │ │ ├── ic_home.png │ │ │ ├── ic_wifi.png │ │ │ ├── ic_bookmark.png │ │ │ └── ic_assignment.png │ │ ├── drawable-xxhdpi │ │ │ ├── ic_date.png │ │ │ ├── ic_home.png │ │ │ ├── ic_wifi.png │ │ │ ├── ic_heart.png │ │ │ ├── ic_bookmark.png │ │ │ └── ic_assignment.png │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── drawable-xxxhdpi │ │ │ ├── ic_date.png │ │ │ ├── ic_heart.png │ │ │ ├── ic_home.png │ │ │ ├── ic_wifi.png │ │ │ ├── ic_bookmark.png │ │ │ └── ic_assignment.png │ │ ├── drawable │ │ │ ├── thelittleprince.png │ │ │ └── ic_launcher_background.xml │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── values │ │ │ ├── styles.xml │ │ │ ├── colors.xml │ │ │ └── strings.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ └── layout │ │ │ ├── activity_main.xml │ │ │ └── activity_custom.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── skydoves │ │ └── indicatorscrollviewdemo │ │ ├── MainActivity.kt │ │ └── CustomActivity.kt └── build.gradle ├── indicatorscrollview ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ └── values │ │ │ └── attrs_scrollviewindicator.xml │ │ └── java │ │ └── com │ │ └── skydoves │ │ └── indicatorscrollview │ │ ├── IndicatorDsl.kt │ │ ├── IndicatorAnimation.kt │ │ ├── ContextExtension.kt │ │ ├── OnScrollChangedListener.kt │ │ ├── ViewExtension.kt │ │ ├── IndicatorExtensions.kt │ │ ├── AnimatorExtension.kt │ │ ├── IndicatorScrollView.kt │ │ ├── IndicatorItem.kt │ │ ├── IndicatorItemView.kt │ │ └── IndicatorView.kt └── build.gradle ├── settings.gradle ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── Bug_report.md │ └── Feature_request.md ├── CODEOWNERS └── pull_request_template.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── spotless.gradle ├── dependencies.gradle ├── .travis.yml ├── spotless.license.kt ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew ├── README.md └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /indicatorscrollview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':indicatorscrollview' 2 | rootProject.name='IndicatorScrollViewDemo' 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: skydoves 2 | custom: ["https://www.paypal.me/skydoves", "https://www.buymeacoffee.com/skydoves"] 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_date.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-hdpi/ic_date.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-hdpi/ic_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-hdpi/ic_wifi.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_date.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-mdpi/ic_date.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-mdpi/ic_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-mdpi/ic_wifi.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-hdpi/ic_heart.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-mdpi/ic_heart.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_date.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xhdpi/ic_date.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xhdpi/ic_heart.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xhdpi/ic_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xhdpi/ic_wifi.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_date.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxhdpi/ic_date.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxhdpi/ic_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxhdpi/ic_wifi.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_bookmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-hdpi/ic_bookmark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_bookmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-mdpi/ic_bookmark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_bookmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xhdpi/ic_bookmark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxhdpi/ic_heart.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_date.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxxhdpi/ic_date.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxxhdpi/ic_heart.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxxhdpi/ic_home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_wifi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxxhdpi/ic_wifi.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/thelittleprince.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable/thelittleprince.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_assignment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-hdpi/ic_assignment.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_assignment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-mdpi/ic_assignment.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_assignment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xhdpi/ic_assignment.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_bookmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxhdpi/ic_bookmark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_bookmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxxhdpi/ic_bookmark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_assignment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxhdpi/ic_assignment.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_assignment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/drawable-xxxhdpi/ic_assignment.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skydoves/IndicatorScrollView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /indicatorscrollview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Oct 25 16:26:47 KST 2020 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-6.7-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /spotless.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.diffplug.spotless" 2 | spotless { 3 | kotlin { 4 | target "**/*.kt" 5 | ktlint("$versions.ktlintGradle").userData(['indent_size': '2', 'continuation_indent_size': '2']) 6 | licenseHeaderFile '../spotless.license.kt' 7 | trimTrailingWhitespace() 8 | endWithNewline() 9 | } 10 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /indicatorscrollview/src/main/res/values/attrs_scrollviewindicator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Something is crashing or not working as intended 4 | 5 | --- 6 | 7 | **Please complete the following information:** 8 | - Library Version [e.g. v1.0.0] 9 | - Affected Device(s) [e.g. Samsung Galaxy s10 with Android 9.0] 10 | 11 | **Describe the Bug:** 12 | 13 | Add a clear description about the problem. 14 | 15 | **Expected Behavior:** 16 | 17 | A clear description of what you expected to happen. 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem?** 8 | 9 | A clear and concise description of what the problem is. 10 | 11 | **Describe the solution you'd like:** 12 | 13 | A clear and concise description of what you want to happen. 14 | 15 | **Describe alternatives you've considered:** 16 | 17 | A clear description of any alternative solutions you've considered. 18 | -------------------------------------------------------------------------------- /dependencies.gradle: -------------------------------------------------------------------------------- 1 | ext.versions = [ 2 | minSdk : 16, 3 | compileSdk : 30, 4 | versionCode : 4, 5 | versionName : '1.0.3', 6 | 7 | gradleBuildTool : '4.1.1', 8 | spotlessGradle : '5.9.0', 9 | ktlintGradle : '0.40.0', 10 | dokkaGradle : '1.4.20', 11 | mavenPublish : '0.13.0', 12 | 13 | kotlin : '1.4.20', 14 | androidxAppcompat: '1.2.0', 15 | 16 | // for demo 17 | googleMaterial : '1.3.0-alpha02', 18 | ] 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | 3 | android: 4 | components: 5 | - tools 6 | - platform-tools 7 | - build-tools-29.0.0 8 | - android-29 9 | - extra-android-support 10 | - extra-android-m2repository 11 | - extra-google-m2repository 12 | 13 | jdk: 14 | - openjdk8 15 | 16 | branches: 17 | except: 18 | - gh-pages 19 | 20 | licenses: 21 | - '.+' 22 | 23 | notifications: 24 | email: false 25 | 26 | cache: 27 | directories: 28 | - $HOME/.gradle 29 | 30 | script: 31 | - chmod +x ./gradlew -------------------------------------------------------------------------------- /spotless.license.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Lines starting with '#' are comments. 2 | # Each line is a file pattern followed by one or more owners. 3 | 4 | # More details are here: https://help.github.com/articles/about-codeowners/ 5 | 6 | # The '*' pattern is global owners. 7 | # Not adding in this PR, but I'd like to try adding a global owner set with the entire team. 8 | # One interpretation of their docs is that global owners are added only if not removed 9 | # by a more local rule. 10 | 11 | # Order is important. The last matching pattern has the most precedence. 12 | # The folders are ordered as follows: 13 | 14 | # In each subsection folders are ordered first by depth, then alphabetically. 15 | # This should make it easy to add new rules without breaking existing ones. 16 | * @skydoves -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Guidelines 2 | Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. 3 | 4 | ### Types of changes 5 | What types of changes does your code introduce? 6 | 7 | - [ ] Bugfix (non-breaking change which fixes an issue) 8 | - [ ] New feature (non-breaking change which adds functionality) 9 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 10 | 11 | ### Preparing a pull request for review 12 | Ensure your change is properly formatted by running: 13 | 14 | ```gradle 15 | $ ./gradlew spotlessApply 16 | ``` 17 | 18 | Please correct any failures before requesting a review. -------------------------------------------------------------------------------- /indicatorscrollview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'org.jetbrains.dokka' 4 | apply from: '../dependencies.gradle' 5 | 6 | android { 7 | compileSdkVersion versions.compileSdk 8 | defaultConfig { 9 | minSdkVersion versions.minSdk 10 | targetSdkVersion versions.compileSdk 11 | versionCode versions.versionCode 12 | versionName versions.versionName 13 | } 14 | buildFeatures { 15 | buildConfig false 16 | } 17 | } 18 | 19 | dependencies { 20 | implementation "androidx.appcompat:appcompat:$versions.androidxAppcompat" 21 | } 22 | 23 | tasks.withType(Javadoc) { 24 | excludes = ['**/*.kt'] 25 | options.addBooleanOption('Xdoclint:none', true) 26 | } 27 | 28 | apply plugin: "com.vanniktech.maven.publish" 29 | apply from: '../spotless.gradle' 30 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply from: "$rootDir/dependencies.gradle" 4 | 5 | android { 6 | compileSdkVersion versions.compileSdk 7 | defaultConfig { 8 | applicationId "com.skydoves.scrollviewindicatordemo" 9 | minSdkVersion versions.minSdk 10 | targetSdkVersion versions.compileSdk 11 | versionCode versions.versionCode 12 | versionName versions.versionName 13 | } 14 | compileOptions { 15 | sourceCompatibility JavaVersion.VERSION_1_8 16 | targetCompatibility JavaVersion.VERSION_1_8 17 | } 18 | buildFeatures { 19 | viewBinding true 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation "com.google.android.material:material:$versions.googleMaterial" 25 | implementation project(":indicatorscrollview") 26 | } 27 | 28 | apply from: "$rootDir/spotless.gradle" -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /indicatorscrollview/src/main/java/com/skydoves/indicatorscrollview/IndicatorDsl.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollview 18 | 19 | @DslMarker 20 | internal annotation class IndicatorItemDsl 21 | 22 | @DslMarker 23 | internal annotation class IndicatorViewDsl 24 | -------------------------------------------------------------------------------- /indicatorscrollview/src/main/java/com/skydoves/indicatorscrollview/IndicatorAnimation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollview 18 | 19 | /** IndicatorAnimation is an animation attribute of [IndicatorView]'s the expanding and collapsing. */ 20 | enum class IndicatorAnimation(val value: Int) { 21 | NORMAL(0), 22 | ACCELERATE(1), 23 | BOUNCE(2) 24 | } 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | /.idea 18 | .gradle/ 19 | build/ 20 | 21 | # Local configuration file (sdk path, etc) 22 | local.properties 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Log Files 28 | *.log 29 | 30 | # Android Studio Navigation editor temp files 31 | .navigation/ 32 | 33 | # Android Studio captures folder 34 | captures/ 35 | 36 | # Intellij 37 | *.iml 38 | .idea/workspace.xml 39 | .idea/tasks.xml 40 | .idea/gradle.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | 44 | # Mac 45 | *.DS_Store 46 | 47 | # Keystore files 48 | *.jks 49 | 50 | # External native build folder generated in Android Studio 2.2 and later 51 | .externalNativeBuild 52 | 53 | # Google Services (e.g. APIs or Firebase) 54 | google-services.json 55 | 56 | # Freeline 57 | freeline.py 58 | freeline/ 59 | freeline_project_description.json -------------------------------------------------------------------------------- /indicatorscrollview/src/main/java/com/skydoves/indicatorscrollview/ContextExtension.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollview 18 | 19 | import android.content.Context 20 | import android.graphics.Point 21 | 22 | /** gets display size as a point. */ 23 | internal fun Context.displaySize(): Point { 24 | return Point( 25 | resources.displayMetrics.widthPixels, 26 | resources.displayMetrics.heightPixels 27 | ) 28 | } 29 | -------------------------------------------------------------------------------- /indicatorscrollview/src/main/java/com/skydoves/indicatorscrollview/OnScrollChangedListener.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollview 18 | 19 | /** Interface definition for a callback to be invoked when a [OnScrollChangedListener] is changed. */ 20 | internal fun interface OnScrollChangedListener { 21 | 22 | /** Invoked when the [OnScrollChangedListener] is changed. */ 23 | fun onChanged(x: Int, y: Int, measuredScrollViewHeight: Int) 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #C51162 4 | #AD1457 5 | #C51162 6 | #2B292B 7 | #424242 8 | #212121 9 | #8effffff 10 | #b2ffffff 11 | #ddffffff 12 | #edf8f8f8 13 | #57A8D8 14 | #FBC02D 15 | #FFD600 16 | #FBC02D 17 | #FFA000 18 | #FFA726 19 | #FF6D00 20 | #81C784 21 | #388E3C 22 | #81D4fA 23 | #0091EA 24 | #AA00FF 25 | #7200CA 26 | 27 | -------------------------------------------------------------------------------- /indicatorscrollview/src/main/java/com/skydoves/indicatorscrollview/ViewExtension.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollview 18 | 19 | import android.view.View 20 | import android.view.ViewGroup 21 | 22 | /** dp size to px size. */ 23 | internal fun View.dp2Px(dp: Int): Float { 24 | val scale = resources.displayMetrics.density 25 | return dp * scale 26 | } 27 | 28 | /** applies [ViewGroup]'s layout params. */ 29 | internal fun ViewGroup.applyLayoutParams(block: ViewGroup.LayoutParams.() -> Unit) { 30 | layoutParams?.let { 31 | val params: ViewGroup.LayoutParams = 32 | (layoutParams as ViewGroup.LayoutParams).apply { block(this) } 33 | layoutParams = params 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /indicatorscrollview/src/main/java/com/skydoves/indicatorscrollview/IndicatorExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @file:Suppress("unused") 18 | 19 | package com.skydoves.indicatorscrollview 20 | 21 | import android.content.Context 22 | import android.view.View 23 | 24 | /** creates an instance of [IndicatorItem] by [IndicatorItem.Builder] using kotlin dsl. */ 25 | @JvmSynthetic 26 | @IndicatorItemDsl 27 | fun indicatorItem(target: View, block: IndicatorItem.Builder.() -> Unit): IndicatorItem = 28 | IndicatorItem.Builder(target).apply(block).build() 29 | 30 | /** creates an instance of [IndicatorView] by [IndicatorView.Builder] using kotlin dsl. */ 31 | @JvmSynthetic 32 | @IndicatorViewDsl 33 | fun indicatorView(context: Context, block: IndicatorView.Builder.() -> Unit): IndicatorView = 34 | IndicatorView.Builder(context).apply(block).build() 35 | -------------------------------------------------------------------------------- /indicatorscrollview/src/main/java/com/skydoves/indicatorscrollview/AnimatorExtension.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollview 18 | 19 | import android.animation.Animator 20 | import android.animation.AnimatorListenerAdapter 21 | import android.view.animation.AccelerateInterpolator 22 | import android.view.animation.BounceInterpolator 23 | import android.view.animation.LinearInterpolator 24 | 25 | internal fun Animator.doAfterFinishLift(doAfterLift: () -> Unit) { 26 | this.addListener(object : AnimatorListenerAdapter() { 27 | override fun onAnimationEnd(animation: Animator?) { 28 | super.onAnimationEnd(animation) 29 | doAfterLift() 30 | } 31 | }) 32 | } 33 | 34 | internal fun Animator.applyInterpolator(indicatorAnimation: IndicatorAnimation) { 35 | when (indicatorAnimation) { 36 | IndicatorAnimation.NORMAL -> this.interpolator = LinearInterpolator() 37 | IndicatorAnimation.ACCELERATE -> this.interpolator = AccelerateInterpolator() 38 | IndicatorAnimation.BOUNCE -> this.interpolator = BounceInterpolator() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019 skydoves (Jaewoong Eum) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | org.gradle.jvmargs=-Xmx4g 18 | 19 | # AndroidX 20 | android.useAndroidX=true 21 | 22 | # Maven 23 | GROUP=com.github.skydoves 24 | POM_ARTIFACT_ID=indicatorscrollview 25 | VERSION_NAME=1.0.5-SNAPSHOT 26 | 27 | POM_NAME=indicatorscrollview 28 | POM_DESCRIPTION=A dynamic way of animating indicators according to positions of a scroll view. 29 | 30 | POM_URL=https://github.com/skydoves/IndicatorScrollView/ 31 | POM_SCM_URL=https://github.com/skydoves/IndicatorScrollView/ 32 | POM_SCM_CONNECTION=scm:git:git://github.com/skydoves/IndicatorScrollView.git 33 | POM_SCM_DEV_CONNECTION=scm:git:git://github.com/skydoves/IndicatorScrollView.git 34 | 35 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 36 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 37 | POM_LICENCE_DIST=repo 38 | 39 | POM_DEVELOPER_ID=skydoves 40 | POM_DEVELOPER_NAME=Jaewoong Eum 41 | POM_DEVELOPER_URL=https://github.com/skydoves/ 42 | 43 | RELEASE_REPOSITORY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/ 44 | SNAPSHOT_REPOSITORY_URL=https://oss.sonatype.org/content/repositories/snapshots/ 45 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/skydoves/indicatorscrollviewdemo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollviewdemo 18 | 19 | import android.os.Bundle 20 | import androidx.appcompat.app.AppCompatActivity 21 | import com.skydoves.indicatorscrollview.IndicatorItem 22 | import com.skydoves.indicatorscrollviewdemo.databinding.ActivityMainBinding 23 | 24 | class MainActivity : AppCompatActivity() { 25 | 26 | override fun onCreate(savedInstanceState: Bundle?) { 27 | super.onCreate(savedInstanceState) 28 | 29 | val binding = ActivityMainBinding.inflate(layoutInflater) 30 | setContentView(binding.root) 31 | 32 | with(binding) { 33 | indicatorScrollView.bindIndicatorView(indicatorView) 34 | 35 | indicatorView + IndicatorItem.Builder(section1).setItemColorResource( 36 | R.color.colorPrimary 37 | ).setItemIconResource(R.drawable.ic_heart).build() 38 | 39 | indicatorView + IndicatorItem.Builder(section2).setItemColorResource( 40 | R.color.md_yellow_200 41 | ).setItemIconResource(R.drawable.ic_assignment).build() 42 | 43 | indicatorView + IndicatorItem.Builder(section3).setItemColorResource( 44 | R.color.md_green_200 45 | ).setItemIconResource(R.drawable.ic_bookmark).build() 46 | 47 | indicatorView + IndicatorItem.Builder(section4).setItemColorResource( 48 | R.color.md_blue_200 49 | ).setItemIconResource(R.drawable.ic_date).build() 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /indicatorscrollview/src/main/java/com/skydoves/indicatorscrollview/IndicatorScrollView.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollview 18 | 19 | import android.content.Context 20 | import android.util.AttributeSet 21 | import androidx.core.widget.NestedScrollView 22 | import kotlin.math.abs 23 | 24 | /** 25 | * IndicatorScrollView is a scrollView for reacting with [IndicatorView] when scroll is changed. 26 | * Extends [NestedScrollView]. 27 | */ 28 | @Suppress("UNUSED_PARAMETER") 29 | class IndicatorScrollView : NestedScrollView, NestedScrollView.OnScrollChangeListener { 30 | 31 | private var onUserScrollChangeListener: OnScrollChangeListener? = null 32 | private var onScrollChangedListener: OnScrollChangedListener? = null 33 | 34 | constructor(context: Context) : super(context) 35 | constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) 36 | constructor(context: Context, attributeSet: AttributeSet, defStyle: Int) : super(context) 37 | 38 | override fun onFinishInflate() { 39 | super.onFinishInflate() 40 | super.setOnScrollChangeListener(this) 41 | } 42 | 43 | override fun setOnScrollChangeListener(onScrollChangeListener: OnScrollChangeListener?) { 44 | super.setOnScrollChangeListener(this) 45 | if (onScrollChangeListener != this) { 46 | this.onUserScrollChangeListener = onScrollChangeListener 47 | } 48 | } 49 | 50 | override fun onScrollChange( 51 | nestedScrollView: NestedScrollView?, 52 | scrollX: Int, 53 | scrollY: Int, 54 | oldScrollX: Int, 55 | oldScrollY: Int 56 | ) { 57 | this.onUserScrollChangeListener?.onScrollChange( 58 | nestedScrollView, scrollX, scrollY, oldScrollX, 59 | oldScrollY 60 | ) 61 | nestedScrollView?.let { 62 | if (it.childCount > 0) { 63 | this.onScrollChangedListener?.onChanged( 64 | scrollX, scrollY, 65 | abs(it.measuredHeight - it.getChildAt(0).measuredHeight) 66 | ) 67 | } 68 | } 69 | } 70 | 71 | /** binds a [IndicatorView] to [IndicatorScrollView]. */ 72 | fun bindIndicatorView(indicatorView: IndicatorView) { 73 | this.onScrollChangedListener = indicatorView 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | 88 | @rem Execute Gradle 89 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 90 | 91 | :end 92 | @rem End local scope for the variables with windows NT shell 93 | if "%ERRORLEVEL%"=="0" goto mainEnd 94 | 95 | :fail 96 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 97 | rem the _cmd.exe /c_ return code! 98 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 99 | exit /b 1 100 | 101 | :mainEnd 102 | if "%OS%"=="Windows_NT" endlocal 103 | 104 | :omega 105 | -------------------------------------------------------------------------------- /app/src/main/java/com/skydoves/indicatorscrollviewdemo/CustomActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollviewdemo 18 | 19 | import android.os.Bundle 20 | import androidx.appcompat.app.AppCompatActivity 21 | import com.skydoves.indicatorscrollview.IndicatorAnimation 22 | import com.skydoves.indicatorscrollview.IndicatorItem 23 | import com.skydoves.indicatorscrollview.indicatorItem 24 | import com.skydoves.indicatorscrollviewdemo.databinding.ActivityCustomBinding 25 | 26 | class CustomActivity : AppCompatActivity() { 27 | 28 | override fun onCreate(savedInstanceState: Bundle?) { 29 | super.onCreate(savedInstanceState) 30 | 31 | val binding = ActivityCustomBinding.inflate(layoutInflater) 32 | setContentView(binding.root) 33 | 34 | with(binding) { 35 | indicatorScrollView.bindIndicatorView(indicatorView) 36 | 37 | /** add an indicator item using [indicatorItem] kotlin dsl with plus operator. */ 38 | indicatorView + indicatorItem(section1) { 39 | setItemColorResource(R.color.colorPrimary) 40 | setItemIconResource(R.drawable.ic_heart) 41 | setIndicatorAnimation(IndicatorAnimation.BOUNCE) 42 | setItemCornerRadius(30f) 43 | } 44 | 45 | /** add an indicator item using [IndicatorItem.Builder] with plus operator. */ 46 | indicatorView + IndicatorItem.Builder(section2) 47 | .setItemColorResource(R.color.md_orange_100) 48 | .setItemIconResource(R.drawable.ic_home) 49 | .setIndicatorAnimation(IndicatorAnimation.BOUNCE) 50 | .setItemCornerRadius(30f) 51 | .build() 52 | 53 | /** add an indicator item using an addIndicatorItem method. */ 54 | indicatorView.addIndicatorItem( 55 | IndicatorItem.Builder(section3) 56 | .setItemColorResource(R.color.md_yellow_200) 57 | .setItemIconResource(R.drawable.ic_assignment) 58 | .setIndicatorAnimation(IndicatorAnimation.BOUNCE) 59 | .setItemCornerRadius(30f) 60 | .build() 61 | ) 62 | 63 | indicatorView + IndicatorItem.Builder(section4) 64 | .setItemColorResource(R.color.md_green_200) 65 | .setItemIconResource(R.drawable.ic_bookmark) 66 | .setIndicatorAnimation(IndicatorAnimation.BOUNCE) 67 | .setItemCornerRadius(30f) 68 | .build() 69 | 70 | indicatorView + IndicatorItem.Builder(section5) 71 | .setItemColorResource(R.color.md_blue_200) 72 | .setItemIconResource(R.drawable.ic_date) 73 | .setIndicatorAnimation(IndicatorAnimation.BOUNCE) 74 | .setItemCornerRadius(30f) 75 | .build() 76 | 77 | indicatorView + IndicatorItem.Builder(section6) 78 | .setItemColorResource(R.color.md_purple_100) 79 | .setItemIconResource(R.drawable.ic_wifi) 80 | .setIndicatorAnimation(IndicatorAnimation.BOUNCE) 81 | .setItemCornerRadius(30f).build() 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /indicatorscrollview/src/main/java/com/skydoves/indicatorscrollview/IndicatorItem.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollview 18 | 19 | import android.graphics.Color 20 | import android.graphics.drawable.Drawable 21 | import android.view.View 22 | import androidx.annotation.ColorInt 23 | import androidx.annotation.ColorRes 24 | import androidx.annotation.DrawableRes 25 | import androidx.annotation.Px 26 | import androidx.core.content.ContextCompat 27 | 28 | /** IndicatorItem is an item data for composing the [IndicatorView]. */ 29 | @Suppress("unused") 30 | class IndicatorItem(val target: View) { 31 | 32 | var color: Int = Color.WHITE 33 | private set 34 | 35 | var icon: Drawable? = null 36 | private set 37 | 38 | var iconTopPadding: Int = 50 39 | private set 40 | 41 | var cornerRadius: Float = 120f 42 | private set 43 | 44 | var duration: Long = 1000L 45 | private set 46 | 47 | var expandedSize: Int = -1 48 | private set 49 | 50 | var indicatorAnimation: IndicatorAnimation = IndicatorAnimation.NORMAL 51 | private set 52 | 53 | /** Builder class for creating an instance of [IndicatorItem]. */ 54 | @IndicatorItemDsl 55 | class Builder(private val target: View) { 56 | private val indicatorItem = IndicatorItem(target) 57 | 58 | /** sets the background color of the indicator item using value. */ 59 | fun setItemColor(@ColorInt value: Int) = apply { this.indicatorItem.color = value } 60 | 61 | /** sets the background color of the item using resource. */ 62 | fun setItemColorResource(@ColorRes value: Int) = apply { 63 | this.indicatorItem.color = ContextCompat.getColor(target.context, value) 64 | } 65 | 66 | /** sets the icon of the indicator item using drawable. */ 67 | fun setItemIcon(value: Drawable?) = apply { this.indicatorItem.icon = value } 68 | 69 | /** sets the icon of the indicator item using resource. */ 70 | fun setItemIconResource(@DrawableRes value: Int) = apply { 71 | this.indicatorItem.icon = ContextCompat.getDrawable(target.context, value) 72 | } 73 | 74 | /** setItemIconTopPadding(12) */ 75 | fun setItemIconTopPadding(@Px value: Int) = apply { this.indicatorItem.iconTopPadding = value } 76 | 77 | /** sets the corner radius of the indicator item. */ 78 | fun setItemCornerRadius(@Px value: Float) = apply { this.indicatorItem.cornerRadius = value } 79 | 80 | /** sets the expanding and collapsing duration. */ 81 | fun setItemDuration(value: Long) = apply { this.indicatorItem.duration = value } 82 | 83 | /** customizes the fully expanded height size. */ 84 | fun setExpandedSize(@Px value: Int) = apply { this.indicatorItem.expandedSize = value } 85 | 86 | /** customizes the indicator animation when expanding and collapsing. */ 87 | fun setIndicatorAnimation(value: IndicatorAnimation) = apply { this.indicatorItem.indicatorAnimation = value } 88 | 89 | /** returns an instance of the [IndicatorView]. */ 90 | fun build() = indicatorItem 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /indicatorscrollview/src/main/java/com/skydoves/indicatorscrollview/IndicatorItemView.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollview 18 | 19 | import android.animation.ValueAnimator 20 | import android.content.Context 21 | import android.graphics.drawable.GradientDrawable 22 | import android.util.AttributeSet 23 | import android.view.Gravity 24 | import android.widget.FrameLayout 25 | import android.widget.ImageView 26 | 27 | /** IndicatorItemView is am internal class for drawing [IndicatorItem] on the [IndicatorView]. */ 28 | internal class IndicatorItemView( 29 | context: Context, 30 | attrs: AttributeSet? = null 31 | ) : FrameLayout(context, attrs) { 32 | 33 | var isExpanding: Boolean = false 34 | private set 35 | 36 | var isExpanded: Boolean = false 37 | private set 38 | 39 | var indicatorItem: IndicatorItem? = null 40 | set(value) { 41 | field = value 42 | updateIndicatorItemView() 43 | } 44 | 45 | private val icon: ImageView = ImageView(context) 46 | 47 | init { 48 | val layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) 49 | layoutParams.gravity = Gravity.CENTER 50 | this.layoutParams = layoutParams 51 | this.icon.layoutParams = layoutParams 52 | addView(this.icon) 53 | invalidate() 54 | } 55 | 56 | private fun updateIndicatorItemView() { 57 | this.indicatorItem?.let { 58 | icon.setImageDrawable(it.icon) 59 | background = GradientDrawable().apply { 60 | cornerRadius = it.cornerRadius 61 | setColor(it.color) 62 | } 63 | } 64 | } 65 | 66 | internal fun expand(minHeight: Int, to: Int) { 67 | this.indicatorItem?.let { item -> 68 | if (!isExpanded && !isExpanding) { 69 | this.isExpanded = true 70 | this.isExpanding = true 71 | ValueAnimator.ofFloat(0f, 1f).apply { 72 | duration = item.duration 73 | applyInterpolator(item.indicatorAnimation) 74 | doAfterFinishLift { isExpanding = false } 75 | addUpdateListener { 76 | val value = it.animatedValue as Float 77 | applyLayoutParams { 78 | var target = minHeight + (to * value).toInt() 79 | if (target >= to) target = to 80 | height = target 81 | } 82 | } 83 | start() 84 | } 85 | } 86 | } 87 | } 88 | 89 | internal fun collapse(minHeight: Int, from: Int) { 90 | this.indicatorItem?.let { item -> 91 | if (isExpanded && !isExpanding) { 92 | this.isExpanded = false 93 | this.isExpanding = true 94 | ValueAnimator.ofFloat(1f, 0f).apply { 95 | duration = item.duration 96 | applyInterpolator(item.indicatorAnimation) 97 | doAfterFinishLift { isExpanding = false } 98 | addUpdateListener { 99 | val value = it.animatedValue as Float 100 | applyLayoutParams { 101 | var target = (from * value).toInt() 102 | if (target <= minHeight) target = minHeight 103 | height = target 104 | } 105 | } 106 | start() 107 | } 108 | } 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | IndicatorScrollView 3 | The grown-ups response, this time, was to advise me to lay aside my drawings of boa constrictors, whether from the inside or the outside, and devote myself instead to geography, history, arithmetic, and grammar. That is why, at the age of six, I gave up what might have been a magnificent career as a painter. I had been disheartened by the failure of my Drawing Number One and my Drawing Number Two. Grown-ups never understand anything by themselves, and it is tiresome for children to be always and forever explaining things to them. 4 | \n\nSo then I chose another profession, and learned to pilot airplanes. I have flown a little over all parts of the world; and it is true that geography has been very useful to me. At a glance I can distinguish China from Arizona. If one gets lost in the night, such knowledge is valuable. 5 | \n\nIn the course of this life I have had a great many encounters with a great many people who have been concerned with matters of consequence. I have lived a great deal among grown-ups. I have seen them intimately, close at hand. And that hasn`t much improved my opinion of them. 6 | \n\nWhenever I met one of them who seemed to me at all clear-sighted, I tried the experiment of showing him my Drawing Number One, which I have always kept. I would try to find out, so, if this was a person of true understanding. But, whoever it was, he, or she, would always say: 7 | And now six years have already gone by.. I have never yet told this story. The companions who met me on my return were well content to see me alive. I was sad, but I told them: "I am tired." 8 | \n\nNow my sorrow is comforted a little. That is to say`not entirely. But I know that he did go back to his planet, because I did not find his body at daybreak. It was not such a heavy body.. and at night I love to listen to the stars. It is like five hundred million little bells.. 9 | \n\nBut there is one extraordinary thing.. when I drew the muzzle for the little prince, I forgot to add the leather strap to it. He will never have been able to fasten it on his sheep. So now I keep wondering: what is happening on his planet? Perhaps the sheep has eaten the flower.. 10 | The inextricable bond between you and the things you “tame” is, essentially, love. What binds the little prince and the fox is their friendship, and for that they will never really be apart or estranged. To be tamed, you need to break down your walls and open yourself up, which is why the little prince also said, “One runs the risk of crying a bit if one allows oneself to be tamed.” 11 | So then the seventh planet was the Earth. 12 | \n\nThe Earth is not just an ordinary planet! One can count, there, 111 kings (not forgetting, to be sure, the Negro kings among them), 7000 geographers, 900,000 businessmen, 7,500,000 tipplers, 311,000,000 conceited menthat is to say, about 2,000,000,000 grown-ups. 13 | \n\nTo give you an idea of the size of the Earth, I will tell you that before the invention of electricity it was necessary to maintain, over the whole of the six continents, a veritable army of 462,511 lamplighters for the street lamps. 14 | Stars mean different things to different people. For travellers, stars tell them where they are, where they are going. For others, they are just little lights in the sky. 15 | For scholars, they are the world of the unknown, yet to be discovered and understood. For my businessman, they are gold. But all stars stay silent. 16 | Of course, I’ll hurt you. Of course, you’ll hurt me. Of course, we will hurt each other. But that is the very condition of existence. To become spring means accepting the risk of winter. To become a presence means accepting the risk of absence. 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 24 | 25 | 30 | 31 | 37 | 38 | 43 | 44 | 45 | 55 | 56 | 63 | 64 | 71 | 72 | 73 | 83 | 84 | 91 | 92 | 99 | 100 | 101 | 111 | 112 | 119 | 120 | 127 | 128 | 129 | 139 | 140 | 147 | 148 | 155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /indicatorscrollview/src/main/java/com/skydoves/indicatorscrollview/IndicatorView.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Designed and developed by 2019 skydoves (Jaewoong Eum) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.skydoves.indicatorscrollview 18 | 19 | import android.content.Context 20 | import android.content.res.TypedArray 21 | import android.util.AttributeSet 22 | import android.widget.FrameLayout 23 | import androidx.annotation.FloatRange 24 | import androidx.annotation.Px 25 | 26 | /** IndicatorView is an indicator layout for reacting with [IndicatorScrollView] when the scroll is changed. */ 27 | @Suppress("unused") 28 | class IndicatorView : FrameLayout, OnScrollChangedListener { 29 | 30 | private val indicatorItemsList = mutableListOf() 31 | private val indicatorItemViewList = mutableListOf() 32 | 33 | @Px 34 | var indicatorItemPadding = dp2Px(6).toInt() 35 | 36 | @FloatRange(from = 0.0, to = 1.0) 37 | var expandingRatio = 0.2f 38 | 39 | @FloatRange(from = 0.0, to = 1.0) 40 | var expandingAllItemRatio = 0.9f 41 | 42 | constructor(context: Context) : super(context) 43 | 44 | constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) { 45 | getAttrs(attributeSet) 46 | } 47 | 48 | constructor(context: Context, attributeSet: AttributeSet, defStyle: Int) : super( 49 | context, 50 | attributeSet, defStyle 51 | ) { 52 | getAttrs(attributeSet, defStyle) 53 | } 54 | 55 | private fun getAttrs(attributeSet: AttributeSet) { 56 | val typedArray = context.obtainStyledAttributes(attributeSet, R.styleable.IndicatorView) 57 | try { 58 | setTypeArray(typedArray) 59 | } finally { 60 | typedArray.recycle() 61 | } 62 | } 63 | 64 | private fun getAttrs(attributeSet: AttributeSet, defStyleAttr: Int) { 65 | val typedArray = 66 | context.obtainStyledAttributes(attributeSet, R.styleable.IndicatorView, defStyleAttr, 0) 67 | try { 68 | setTypeArray(typedArray) 69 | } finally { 70 | typedArray.recycle() 71 | } 72 | } 73 | 74 | private fun setTypeArray(a: TypedArray) { 75 | this.indicatorItemPadding = 76 | a.getDimensionPixelSize(R.styleable.IndicatorView_indicator_itemPadding, this.indicatorItemPadding) 77 | this.expandingRatio = 78 | a.getFloat(R.styleable.IndicatorView_indicator_expandingRatio, this.expandingRatio) 79 | this.expandingAllItemRatio = 80 | a.getFloat(R.styleable.IndicatorView_indicator_expandingAllItemRatio, this.expandingAllItemRatio) 81 | } 82 | 83 | override fun onFinishInflate() { 84 | super.onFinishInflate() 85 | post { onChanged(0, 0, 0) } 86 | } 87 | 88 | /** add an [IndicatorItem] for composing [IndicatorView]. */ 89 | fun addIndicatorItem(indicatorItem: IndicatorItem) { 90 | indicatorItem.target.post { 91 | val indicatorItemView = IndicatorItemView(context) 92 | addItem(indicatorItem, indicatorItemView).apply { 93 | this.indicatorItem = indicatorItem 94 | this.layoutParams = LayoutParams(getStandardSize(), getStandardSize()) 95 | this.y = indicatorItem.target.y 96 | } 97 | addView(indicatorItemView) 98 | invalidate() 99 | } 100 | } 101 | 102 | /** add a list of [IndicatorItem] for composing [IndicatorView]. */ 103 | fun addIndicatorItemList(indicatorItemList: List) { 104 | indicatorItemList.forEach(::addIndicatorItem) 105 | } 106 | 107 | private fun addItem( 108 | indicatorItem: IndicatorItem, 109 | indicatorItemView: IndicatorItemView 110 | ): IndicatorItemView { 111 | this.indicatorItemsList.add(indicatorItem) 112 | this.indicatorItemViewList.add(indicatorItemView) 113 | return indicatorItemView 114 | } 115 | 116 | private fun getStandardSize() = width - paddingLeft - paddingRight 117 | 118 | operator fun plus(indicatorItem: IndicatorItem) = addIndicatorItem(indicatorItem) 119 | 120 | operator fun plus(indicatorItemList: List) = addIndicatorItemList(indicatorItemList) 121 | 122 | override fun onChanged(x: Int, y: Int, measuredScrollViewHeight: Int) { 123 | if (y == 0 && expandingRatio != 0f) return 124 | post { 125 | for (index in 0 until this.indicatorItemsList.size) { 126 | var height = this.indicatorItemsList[index].expandedSize 127 | if (index == this.indicatorItemsList.size - 1 && height == -1) { 128 | height = 129 | (this.height - this.indicatorItemViewList[index].y - this.indicatorItemPadding).toInt() 130 | } else if (height == -1) { 131 | height = 132 | (this.indicatorItemViewList[index + 1].y - this.indicatorItemViewList[index].y - this.indicatorItemPadding).toInt() 133 | } 134 | if (this.indicatorItemViewList[index].y - y < context.displaySize().y * this.expandingRatio) { 135 | this.indicatorItemViewList[index].expand(getStandardSize(), height) 136 | } else if (((measuredScrollViewHeight * expandingAllItemRatio).toInt() > y)) { 137 | this.indicatorItemViewList[index].collapse(getStandardSize(), height) 138 | } else { 139 | this.indicatorItemViewList[index].expand(getStandardSize(), height) 140 | } 141 | } 142 | } 143 | } 144 | 145 | /** Builder class for creating an instance of [IndicatorView]. */ 146 | @IndicatorViewDsl 147 | class Builder(context: Context) { 148 | private val indicatorView = IndicatorView(context) 149 | 150 | fun setIndicatorItemPadding(@Px value: Int) = apply { this.indicatorView.indicatorItemPadding = value } 151 | 152 | fun setExpandingRatio(@FloatRange(from = 0.0, to = 1.0) value: Float) = apply { this.indicatorView.expandingRatio = value } 153 | 154 | fun setExpandingAllItemRatio(@FloatRange(from = 0.0, to = 1.0) value: Float) = apply { this.indicatorView.expandingAllItemRatio = value } 155 | 156 | fun build() = this.indicatorView 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_custom.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 24 | 25 | 30 | 31 | 37 | 38 | 43 | 44 | 45 | 55 | 56 | 63 | 64 | 71 | 72 | 73 | 83 | 84 | 91 | 92 | 99 | 100 | 101 | 111 | 112 | 119 | 120 | 127 | 128 | 129 | 139 | 140 | 147 | 148 | 155 | 156 | 157 | 167 | 168 | 175 | 176 | 183 | 184 | 185 | 195 | 196 | 203 | 204 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IndicatorScrollView 2 | 3 |

4 | License 5 | API 6 | Build Status 7 | Javadoc 8 |

9 | 10 |

11 | 🧀 A dynamic way that animates indicators according to positions of a scroll view.
12 |

13 | 14 |

15 | 16 | 17 |

18 | 19 | ## Including in your project 20 | [![Maven Central](https://img.shields.io/maven-central/v/com.github.skydoves/indicatorscrollview.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.skydoves%22%20AND%20a:%22indicatorscrollview%22) 21 | [![JitPack](https://jitpack.io/v/skydoves/IndicatorScrollView.svg)](https://jitpack.io/#skydoves/IndicatorScrollView)
22 | Add below codes to your **root** `build.gradle` file (not your module build.gradle file). 23 | ```gradle 24 | allprojects { 25 | repositories { 26 | mavenCentral() 27 | } 28 | } 29 | ``` 30 | And add a dependency code to your **module**'s `build.gradle` file. 31 | ```gradle 32 | dependencies { 33 | implementation "com.github.skydoves:indicatorscrollview:1.0.4" 34 | } 35 | ``` 36 | 37 | ## Usage 38 | Add following XML namespace inside your XML layout file. 39 | 40 | ```gradle 41 | xmlns:app="http://schemas.android.com/apk/res-auto" 42 | ``` 43 | 44 | ### IndicatorScrollView & indicatorView in layout 45 | Here is a basic example of implementing `IndicatorScrollView` and `indicatorView`. 46 | 47 | ```gradle 48 | 54 | 55 | 59 | 60 | 71 | 72 | 77 | 78 | // some complicated views.. 79 | 80 | 84 | 85 | 91 | 92 | 93 | ``` 94 | 95 | ### IndicatorScrollView 96 | IndicatorScrollView is a scrollView for reacting with `IndicatorView` when scroll is changed.
97 | It extends `NestedScrollView`. So it must have a ViewGroup child like what `LinearLayout` or `RelativeLayout`. 98 | 99 | ### IndicatorView 100 | IndicatorView is an indicator view for reacting to `IndicatorScrollView` when the scroll is changed.
101 | It should be used in `IndicatorScrollView`. 102 | 103 | #### Create using builder class 104 | We can create an instance of the `IndicatorView` using `IndicatorView.Builder` class. 105 | ```kotlin 106 | val indicatorView = IndicatorView.Builder(this) 107 | .setIndicatorItemPadding(16) 108 | .setExpandingRatio(0.2f) 109 | .setExpandingAllItemRatio(1.0f) 110 | .build() 111 | ``` 112 | 113 | ### Binding 114 | We should bind an `IndicatorView` to `IndicatorScrollView` like bellow. 115 | ```kotlin 116 | indicatorScrollView.bindIndicatorView(indicatorView) 117 | ``` 118 | 119 | ### IndicatorItem 120 | IndicatorItem is an attribute item data for composing the `IndicatorView`.
121 | We can create an instance of the `IndicatorItem` using the `IndicatorItem.Builder` class. 122 | 123 | ```kotlin 124 | val myIndicatorItem = 125 | IndicatorItem.Builder(section1) // section1 is the target view for the start of expanding. 126 | .setItemColor(myColor) // sets the background color of the indicator item using value. 127 | .setItemColorResource(R.color.colorPrimary) // sets the background color of the item using resource. 128 | .setItemIcon(myIcon) // sets the icon of the indicator item using drawable. 129 | .setItemIconResource(R.drawable.ic_heart) // sets the icon of the indicator item using resource. 130 | .setItemDuration(400) // sets the expanding and collapsing duration. 131 | .setItemCornerRadius(40f) // sets the corner radius of the indicator item. 132 | .setItemIconTopPadding(12) // sets the padding top value between the indicator items. 133 | .setExpandedSize(600) // customizes the fully expanded height size. 134 | .build() 135 | ``` 136 | We can create it using kotlin dsl. 137 | ```kotlin 138 | val myIndicatorItem = indicatorItem(section1) { 139 | setItemColor(myColor) // sets the background color of the indicator item using value. 140 | setItemColorResource(R.color.colorPrimary) // sets the background color of the item using resource. 141 | setItemIcon(myIcon) // sets the icon of the indicator item using drawable. 142 | setItemIconResource(R.drawable.ic_heart) // sets the icon of the indicator item using resource. 143 | setItemDuration(400) // sets the expanding and collapsing duration. 144 | setItemCornerRadius(40f) // sets the corner radius of the indicator item. 145 | setItemIconTopPadding(12) // sets the padding top value between the indicator items. 146 | setExpandedSize(600) // customizes the fully expanded height size. 147 | } 148 | ``` 149 | 150 | And add the instance of the `IndicatorItem` to `IndicatorView`. 151 | 152 | ```kotlin 153 | indicatorView.addIndicatorItem(myIndicatorItem) 154 | 155 | // or we can use plus operator. 156 | indicatorView + myIndicatorItem 157 | ``` 158 | 159 | ### IndicatorAnimation 160 | We can customize the expanding and collapsing animation.
161 | ```kotlin 162 | IndicatorAnimation.NORMAL 163 | IndicatorAnimation.ACCELERATE 164 | IndicatorAnimation.BOUNCE 165 | ``` 166 | 167 | NORMAL | ACCELERATE | BOUNCE 168 | | :---------------: | :---------------: | :---------------: | 169 | | | | 170 | 171 | ## IndicatorView Attributes 172 | Attributes | Type | Default | Description 173 | --- | --- | --- | --- 174 | expandingRatio | Float | 0.2 | expands when an indicator item reaches the display's height ratio. 175 | expandingAllItemRatio | Float | 0.9 | expands all items when scroll reaches a specific position ratio. 176 | itemPadding | Dimension | 6dp | padding size between indicator items. 177 | 178 | ## Find this library useful? :heart: 179 | Support it by joining __[stargazers](https://github.com/skydoves/IndicatorScrollView/stargazers)__ for this repository. :star:
180 | And __[follow](https://github.com/skydoves)__ me for my next creations! 🤩 181 | 182 | # License 183 | ```xml 184 | Copyright 2019 skydoves (Jaewoong Eum) 185 | 186 | Licensed under the Apache License, Version 2.0 (the "License"); 187 | you may not use this file except in compliance with the License. 188 | You may obtain a copy of the License at 189 | 190 | http://www.apache.org/licenses/LICENSE-2.0 191 | 192 | Unless required by applicable law or agreed to in writing, software 193 | distributed under the License is distributed on an "AS IS" BASIS, 194 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 195 | See the License for the specific language governing permissions and 196 | limitations under the License. 197 | ``` 198 | 199 | 200 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------