├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── 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
│ │ ├── layout
│ │ │ ├── fragment_test.xml
│ │ │ └── activity_main.xml
│ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ └── drawable
│ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ └── cn
│ │ │ └── szx
│ │ │ └── myindicator
│ │ │ ├── TestFragment.java
│ │ │ ├── MainActivity.java
│ │ │ └── SimpleViewpagerIndicator.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── expand.gif
├── default.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── .idea
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
└── misc.xml
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/expand.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/al4fun/SimpleViewpagerIndicator/HEAD/expand.gif
--------------------------------------------------------------------------------
/default.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/al4fun/SimpleViewpagerIndicator/HEAD/default.gif
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/al4fun/SimpleViewpagerIndicator/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SimpleViewpagerIndicator
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/al4fun/SimpleViewpagerIndicator/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/al4fun/SimpleViewpagerIndicator/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/al4fun/SimpleViewpagerIndicator/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/al4fun/SimpleViewpagerIndicator/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/al4fun/SimpleViewpagerIndicator/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/al4fun/SimpleViewpagerIndicator/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/al4fun/SimpleViewpagerIndicator/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/al4fun/SimpleViewpagerIndicator/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/al4fun/SimpleViewpagerIndicator/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/al4fun/SimpleViewpagerIndicator/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Mar 29 14:31:40 CST 2018
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-4.1-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 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/szx/myindicator/TestFragment.java:
--------------------------------------------------------------------------------
1 | package cn.szx.myindicator;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | public class TestFragment extends Fragment {
11 |
12 | @Nullable
13 | @Override
14 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
15 | return inflater.inflate(R.layout.fragment_test, container, false);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 |
6 | defaultConfig {
7 | applicationId "cn.szx.myindicator"
8 | minSdkVersion 15
9 | targetSdkVersion 22
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 |
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | implementation fileTree(include: ['*.jar'], dir: 'libs')
24 | implementation 'com.android.support:appcompat-v7:26.1.0'
25 | }
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 写这个小控件是因为最近负责维护的一款app大改版,设计师给了一个新的ViewPager导航样式,但找了几个常用的导航控件发现都无法100%实现设计师给的效果,于是就干脆自己动手丰衣足食了。
2 |
3 | 控件只有一个单独的java类,代码也很简单,放出来希望能帮到需要的人。
4 |
5 | ## 效果
6 |
7 | 控件提供了比较丰富的可配置选项,下面是两个例子:
8 |
9 | 1. 所有配置项均使用默认值(tab宽度包裹内容、indicator与文字等宽......):
10 |
11 | 
12 |
13 | 2. tab宽度平分父控件剩余空间、indicator与tab等宽......:
14 |
15 | 
16 |
17 | ## 配置项
18 |
19 | 在调用setViewPager前,使用一系列setXXX方法进行设置即可,支持链式调用:
20 |
21 | ```java
22 | indicator.setExpand(true)//设置tab宽度为包裹内容还是平分父控件剩余空间,默认值:false,包裹内容
23 | .setIndicatorWrapText(false)//设置indicator是与文字等宽还是与整个tab等宽,默认值:true,与文字等宽
24 | .setIndicatorColor(Color.parseColor("#ff3300"))//indicator颜色
25 | .setIndicatorHeight(2)//indicator高度
26 | .setShowUnderline(true, Color.parseColor("#dddddd"), 2)//设置是否展示underline,默认不展示
27 | .setShowDivider(true, Color.parseColor("#dddddd"), 10, 1)//设置是否展示分隔线,默认不展示
28 | .setTabTextSize(16)//文字大小
29 | .setTabTextColor(Color.parseColor("#ff999999"))//文字颜色
30 | .setTabTypeface(null)//字体
31 | .setTabTypefaceStyle(Typeface.NORMAL)//字体样式:粗体、斜体等
32 | .setTabBackgroundResId(0)//设置tab的背景
33 | .setTabPadding(0)//设置tab的左右padding
34 | .setSelectedTabTextSize(20)//被选中的文字大小
35 | .setSelectedTabTextColor(Color.parseColor("#ff3300"))//被选中的文字颜色
36 | .setSelectedTabTypeface(null)
37 | .setSelectedTabTypefaceStyle(Typeface.BOLD)
38 | .setScrollOffset(120);//滚动偏移量
39 |
40 | indicator.setViewPager(viewPager);
41 | ```
42 |
43 | 所有的配置项均有默认值,也就是说不进行任何设置也是可以的,效果参考上面的第一张图。
44 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/szx/myindicator/MainActivity.java:
--------------------------------------------------------------------------------
1 | package cn.szx.myindicator;
2 |
3 | import android.graphics.Color;
4 | import android.graphics.Typeface;
5 | import android.os.Bundle;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v4.app.FragmentManager;
8 | import android.support.v4.app.FragmentPagerAdapter;
9 | import android.support.v4.view.ViewPager;
10 | import android.support.v7.app.AppCompatActivity;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 | SimpleViewpagerIndicator indicator;
14 | ViewPager viewPager;
15 |
16 | String[] pageTitles = {"记录", "排行", "魔兽世界", "EA"};
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 |
23 | initView();
24 | }
25 |
26 | private void initView() {
27 | viewPager = findViewById(R.id.viewpager);
28 | viewPager.setAdapter(new VpAdapter(getSupportFragmentManager()));
29 |
30 | indicator = findViewById(R.id.indicator);
31 | //indicator.setExpand(true)//设置tab宽度为包裹内容还是平分父控件剩余空间,默认值:false,包裹内容
32 | // .setIndicatorWrapText(false)//设置indicator是与文字等宽还是与整个tab等宽,默认值:true,与文字等宽
33 | // .setIndicatorColor(Color.parseColor("#ff3300"))//indicator颜色
34 | // .setIndicatorHeight(2)//indicator高度
35 | // .setShowUnderline(true, Color.parseColor("#dddddd"), 2)//设置是否展示underline,默认不展示
36 | // .setShowDivider(true, Color.parseColor("#dddddd"), 10, 1)//设置是否展示分隔线,默认不展示
37 | // .setTabTextSize(16)//文字大小
38 | // .setTabTextColor(Color.parseColor("#ff999999"))//文字颜色
39 | // .setTabTypeface(null)//字体
40 | // .setTabTypefaceStyle(Typeface.NORMAL)//字体样式:粗体、斜体等
41 | // .setTabBackgroundResId(0)//设置tab的背景
42 | // .setTabPadding(0)//设置tab的左右padding
43 | // .setSelectedTabTextSize(20)//被选中的文字大小
44 | // .setSelectedTabTextColor(Color.parseColor("#ff3300"))//被选中的文字颜色
45 | // .setSelectedTabTypeface(null)
46 | // .setSelectedTabTypefaceStyle(Typeface.BOLD)
47 | // .setScrollOffset(120);//滚动偏移量
48 | indicator.setViewPager(viewPager);
49 | indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
50 | @Override
51 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
52 |
53 | }
54 |
55 | @Override
56 | public void onPageSelected(int position) {
57 |
58 | }
59 |
60 | @Override
61 | public void onPageScrollStateChanged(int state) {
62 |
63 | }
64 | });
65 | }
66 |
67 | class VpAdapter extends FragmentPagerAdapter {
68 | VpAdapter(FragmentManager fm) {
69 | super(fm);
70 | }
71 |
72 | @Override
73 | public int getCount() {
74 | return 8;
75 | }
76 |
77 | @Override
78 | public CharSequence getPageTitle(int position) {
79 | return pageTitles[position % 4];
80 | }
81 |
82 | @Override
83 | public Fragment getItem(int position) {
84 | return new TestFragment();
85 | }
86 | }
87 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/szx/myindicator/SimpleViewpagerIndicator.java:
--------------------------------------------------------------------------------
1 | package cn.szx.myindicator;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.Paint.Style;
8 | import android.graphics.Typeface;
9 | import android.os.Build;
10 | import android.support.annotation.Nullable;
11 | import android.support.v4.view.ViewPager;
12 | import android.support.v4.view.ViewPager.OnPageChangeListener;
13 | import android.util.AttributeSet;
14 | import android.util.TypedValue;
15 | import android.view.Gravity;
16 | import android.view.View;
17 | import android.view.ViewTreeObserver.OnGlobalLayoutListener;
18 | import android.widget.HorizontalScrollView;
19 | import android.widget.LinearLayout;
20 | import android.widget.TextView;
21 |
22 | /**
23 | * 使用方式:
24 | * --在调用setViewPager之前使用setxxx方法进行样式设置,支持链式调用
25 | * --调用setViewPager方法将viewPager绑定到simpleViewpagerIndicator(viewPager的adapter必须实现getPageTitle方法)
26 | * --调用setOnPageChangeListener来设置viewPager的页面切换监听
27 | */
28 | public class SimpleViewpagerIndicator extends HorizontalScrollView {
29 |
30 | //配置属性 START-------------------------------------------------------------------------------------
31 |
32 | /*
33 | * true:每个tab宽度为平分父控件剩余空间
34 | * false:每个tab宽度为包裹内容
35 | */
36 | private boolean expand = false;
37 |
38 | /*
39 | * 指示器(被选中的tab下的短横线)
40 | */
41 | private boolean indicatorWrapText = true;//true:indicator与文字等长;false:indicator与整个tab等长
42 | private int indicatorColor = Color.parseColor("#ff666666");
43 | private int indicatorHeight = 2;//dp
44 |
45 | /*
46 | * 底线(指示器的背景滑轨)
47 | */
48 | private boolean showUnderline = false;//是否展示底线
49 | private int underlineColor;
50 | private int underlineHeight;//dp
51 |
52 | /*
53 | * tab之间的分割线
54 | */
55 | private boolean showDivider = false;//是否展示分隔线
56 | private int dividerColor;
57 | private int dividerPadding;//分隔线上下的padding,dp
58 | private int dividerWidth;//分隔线宽度,dp
59 |
60 | /*
61 | * tab
62 | */
63 | private int tabTextSize = 16;//tab字号,dp
64 | private int tabTextColor = Color.parseColor("#ff999999");//tab字色
65 | private Typeface tabTypeface = null;//tab字体
66 | private int tabTypefaceStyle = Typeface.NORMAL;//tab字体样式
67 | private int tabBackgroundResId = 0;//每个tab的背景资源id
68 | private int tabPadding = 24;//每个tab的左右内边距,dp
69 |
70 | /*
71 | * 被选中的tab
72 | */
73 | private int selectedTabTextSize = 16;//dp
74 | private int selectedTabTextColor = Color.parseColor("#ff666666");
75 | private Typeface selectedTabTypeface = null;
76 | private int selectedTabTypefaceStyle = Typeface.BOLD;
77 |
78 | /*
79 | * scrollView整体滚动的偏移量,dp
80 | */
81 | private int scrollOffset = 100;
82 |
83 | //配置属性 End---------------------------------------------------------------------------------------
84 |
85 | private LinearLayout.LayoutParams wrapTabLayoutParams;
86 | private LinearLayout.LayoutParams expandTabLayoutParams;
87 |
88 | private Paint rectPaint;
89 | private Paint dividerPaint;
90 | private Paint measureTextPaint;//测量文字宽度用的画笔
91 |
92 | private final PageListener pageListener = new PageListener();
93 | private OnPageChangeListener userPageListener;
94 |
95 | private LinearLayout tabsContainer;//tab的容器
96 | private ViewPager viewPager;
97 |
98 | private int currentPosition = 0;//viewPager当前页面
99 | private float currentPositionOffset = 0f;//viewPager当前页面的偏移百分比(取值:0~1)
100 | private int selectedPosition = 0;//viewPager当前被选中的页面
101 |
102 | private int tabCount;
103 | private int lastScrollX = 0;
104 |
105 | public SimpleViewpagerIndicator(Context context) {
106 | this(context, null);
107 | }
108 |
109 | public SimpleViewpagerIndicator(Context context, AttributeSet attrs) {
110 | this(context, attrs, 0);
111 | }
112 |
113 | public SimpleViewpagerIndicator(Context context, AttributeSet attrs, int defStyle) {
114 | super(context, attrs, defStyle);
115 | setFillViewport(true);
116 | setWillNotDraw(false);
117 | }
118 |
119 | public SimpleViewpagerIndicator setViewPager(ViewPager viewPager) {
120 | this.viewPager = viewPager;
121 | if (viewPager.getAdapter() == null) {
122 | throw new IllegalStateException("ViewPager does not have adapter instance.");
123 | }
124 |
125 | viewPager.setOnPageChangeListener(pageListener);
126 |
127 | init();
128 | initView();
129 |
130 | return this;
131 | }
132 |
133 | public SimpleViewpagerIndicator setOnPageChangeListener(OnPageChangeListener listener) {
134 | this.userPageListener = listener;
135 | return this;
136 | }
137 |
138 | private void init() {
139 | /*
140 | * 将dp换算为px
141 | */
142 | float density = getContext().getResources().getDisplayMetrics().density;
143 | indicatorHeight = (int) (indicatorHeight * density);
144 | underlineHeight = (int) (underlineHeight * density);
145 | dividerPadding = (int) (dividerPadding * density);
146 | dividerWidth = (int) (dividerWidth * density);
147 | tabTextSize = (int) (tabTextSize * density);
148 | tabPadding = (int) (tabPadding * density);
149 | selectedTabTextSize = (int) (selectedTabTextSize * density);
150 | scrollOffset = (int) (scrollOffset * density);
151 |
152 | /*
153 | * 创建tab的容器(LinearLayout)
154 | */
155 | tabsContainer = new LinearLayout(getContext());
156 | tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
157 | tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
158 | addView(tabsContainer);
159 |
160 | /*
161 | * 创建画笔
162 | */
163 | rectPaint = new Paint();
164 | rectPaint.setAntiAlias(true);
165 | rectPaint.setStyle(Style.FILL);
166 |
167 | dividerPaint = new Paint();
168 | dividerPaint.setAntiAlias(true);
169 | dividerPaint.setStrokeWidth(dividerWidth);
170 |
171 | measureTextPaint = new Paint();
172 | measureTextPaint.setTextSize(selectedTabTextSize);
173 |
174 | /*
175 | * 创建两个Tab的LayoutParams,一个为宽度包裹内容,一个为宽度等分父控件剩余空间
176 | */
177 | wrapTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);//宽度包裹内容
178 | expandTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);//宽度等分
179 | }
180 |
181 | private void initView() {
182 | //注意:currentPosition和selectedPosition的含义并不相同,它们分别在onPageScroll和onPageSelected中被赋值
183 | //在从tab1往tab2滑动的过程中,selectedPosition会比currentPosition先由1变成2
184 | currentPosition = viewPager.getCurrentItem();
185 | selectedPosition = viewPager.getCurrentItem();
186 |
187 | tabsContainer.removeAllViews();
188 | tabCount = viewPager.getAdapter().getCount();
189 |
190 | //创建tab并添加到tabsContainer中
191 | for (int i = 0; i < tabCount; i++) {
192 | addTab(i, viewPager.getAdapter().getPageTitle(i).toString());
193 | }
194 |
195 | //遍历tab,设置tab文字大小和样式
196 | updateTextStyle();
197 |
198 | //滚动scrollView
199 | getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
200 | @Override
201 | public void onGlobalLayout() {
202 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
203 | getViewTreeObserver().removeGlobalOnLayoutListener(this);
204 | } else {
205 | getViewTreeObserver().removeOnGlobalLayoutListener(this);
206 | }
207 |
208 | scrollToChild(currentPosition, 0);//滚动scrollView
209 | }
210 | });
211 | }
212 |
213 | /**
214 | * 添加tab
215 | */
216 | private void addTab(final int position, String title) {
217 | TextView tab = new TextView(getContext());
218 |
219 | tab.setGravity(Gravity.CENTER);
220 | tab.setSingleLine();
221 | tab.setText(title);
222 | if (tabBackgroundResId != 0) {
223 | tab.setBackgroundResource(tabBackgroundResId);
224 | }
225 | tab.setPadding(tabPadding, 0, tabPadding, 0);
226 | tab.setOnClickListener(new OnClickListener() {
227 | @Override
228 | public void onClick(View v) {
229 | viewPager.setCurrentItem(position);
230 | }
231 | });
232 |
233 | tabsContainer.addView(tab, position, expand ? expandTabLayoutParams : wrapTabLayoutParams);
234 | }
235 |
236 | /**
237 | * 遍历tab,设置tab文字大小和样式
238 | */
239 | private void updateTextStyle() {
240 | for (int i = 0; i < tabCount; i++) {
241 | TextView tvTab = (TextView) tabsContainer.getChildAt(i);
242 |
243 | if (i == selectedPosition) {//被选中的tab
244 | tvTab.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTabTextSize);
245 | tvTab.setTypeface(selectedTabTypeface, selectedTabTypefaceStyle);
246 | tvTab.setTextColor(selectedTabTextColor);
247 | } else {//未被选中的tab
248 | tvTab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
249 | tvTab.setTypeface(tabTypeface, tabTypefaceStyle);
250 | tvTab.setTextColor(tabTextColor);
251 | }
252 | }
253 | }
254 |
255 | /**
256 | * 滚动scrollView
257 | *
258 | * 注意:当普通文字字号(tabTextSize)与被选中的文字字号(selectedTabTextSize)相差过大,且tab的宽度模式为包裹内容(expand = false)时,
259 | * 由于文字选中状态切换时文字宽度突变,造成tab宽度突变,可能导致scrollView在滚动时出现轻微抖动。
260 | * 因此,当普通文字字号(tabTextSize)与被选中的文字字号(selectedTabTextSize)相差过大时,应避免使tab宽度包裹内容(expand = false)。
261 | */
262 | private void scrollToChild(int position, int offset) {
263 | if (tabCount == 0) return;
264 |
265 | //getLeft():tab相对于父控件,即tabsContainer的left
266 | int newScrollX = tabsContainer.getChildAt(position).getLeft() + offset;
267 |
268 | //附加一个偏移量,防止当前选中的tab太偏左
269 | //可以去掉看看是什么效果
270 | if (position > 0 || offset > 0) {
271 | newScrollX -= scrollOffset;
272 | }
273 |
274 | if (newScrollX != lastScrollX) {
275 | lastScrollX = newScrollX;
276 | scrollTo(newScrollX, 0);
277 | }
278 | }
279 |
280 | /**
281 | * 绘制indicator、underline和divider
282 | */
283 | @Override
284 | protected void onDraw(Canvas canvas) {
285 | super.onDraw(canvas);
286 |
287 | if (isInEditMode() || tabCount == 0) return;
288 |
289 | final int height = getHeight();
290 |
291 | /*
292 | * 绘制divider
293 | */
294 | if (showDivider) {
295 | dividerPaint.setColor(dividerColor);
296 | for (int i = 0; i < tabCount - 1; i++) {
297 | View tab = tabsContainer.getChildAt(i);
298 | canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
299 | }
300 | }
301 |
302 | /*
303 | * 绘制underline(indicator的背景线)
304 | */
305 | if (showUnderline) {
306 | rectPaint.setColor(underlineColor);
307 | canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);
308 | }
309 |
310 | /*
311 | * 绘制indicator
312 | */
313 | if (indicatorWrapText) {//indicator与文字等长
314 | rectPaint.setColor(indicatorColor);
315 | getTextLocation(currentPosition);
316 | float lineLeft = textLocation.left;
317 | float lineRight = textLocation.right;
318 | if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
319 | getTextLocation(currentPosition + 1);
320 | final float nextLeft = textLocation.left;
321 | final float nextRight = textLocation.right;
322 |
323 | lineLeft = lineLeft + (nextLeft - lineLeft) * currentPositionOffset;
324 | lineRight = lineRight + (nextRight - lineRight) * currentPositionOffset;
325 | }
326 | canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
327 | } else {//indicator与tab等长
328 | rectPaint.setColor(indicatorColor);
329 | View currentTab = tabsContainer.getChildAt(currentPosition);
330 | float lineLeft = currentTab.getLeft();
331 | float lineRight = currentTab.getRight();
332 | if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
333 | View nextTab = tabsContainer.getChildAt(currentPosition + 1);
334 | final float nextLeft = nextTab.getLeft();
335 | final float nextRight = nextTab.getRight();
336 |
337 | lineLeft = lineLeft + (nextLeft - lineLeft) * currentPositionOffset;
338 | lineRight = lineRight + (nextRight - lineRight) * currentPositionOffset;
339 | }
340 | canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
341 | }
342 | }
343 |
344 | /**
345 | * 获得指定tab中,文字的left和right
346 | */
347 | private void getTextLocation(int position) {
348 | View tab = tabsContainer.getChildAt(position);
349 | String tabText = viewPager.getAdapter().getPageTitle(position).toString();
350 |
351 | float textWidth = measureTextPaint.measureText(tabText);
352 | int tabWidth = tab.getWidth();
353 | textLocation.left = tab.getLeft() + (int) ((tabWidth - textWidth) / 2);
354 | textLocation.right = tab.getRight() - (int) ((tabWidth - textWidth) / 2);
355 | }
356 |
357 | private LeftRight textLocation = new LeftRight();
358 |
359 | class LeftRight {
360 | int left, right;
361 | }
362 |
363 | private class PageListener implements OnPageChangeListener {
364 | @Override
365 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
366 | currentPosition = position;
367 | currentPositionOffset = positionOffset;
368 |
369 | //scrollView滚动
370 | scrollToChild(position, (int) (positionOffset * tabsContainer.getChildAt(position).getWidth()));
371 |
372 | invalidate();//invalidate后onDraw会被调用,绘制indicator、divider等
373 |
374 | if (userPageListener != null) {
375 | userPageListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
376 | }
377 | }
378 |
379 | @Override
380 | public void onPageScrollStateChanged(int state) {
381 | if (state == ViewPager.SCROLL_STATE_IDLE) {
382 | scrollToChild(viewPager.getCurrentItem(), 0);//scrollView滚动
383 | }
384 |
385 | if (userPageListener != null) {
386 | userPageListener.onPageScrollStateChanged(state);
387 | }
388 | }
389 |
390 | @Override
391 | public void onPageSelected(int position) {
392 | selectedPosition = position;
393 | updateTextStyle();//更新tab文字大小和样式
394 |
395 | if (userPageListener != null) {
396 | userPageListener.onPageSelected(position);
397 | }
398 | }
399 | }
400 |
401 | //setter--------------------------------------------------------------------------------------------
402 |
403 | public SimpleViewpagerIndicator setExpand(boolean expand) {
404 | this.expand = expand;
405 | return this;
406 | }
407 |
408 | public SimpleViewpagerIndicator setIndicatorWrapText(boolean indicatorWrapText) {
409 | this.indicatorWrapText = indicatorWrapText;
410 | return this;
411 | }
412 |
413 | public SimpleViewpagerIndicator setIndicatorColor(int indicatorColor) {
414 | this.indicatorColor = indicatorColor;
415 | return this;
416 | }
417 |
418 | public SimpleViewpagerIndicator setIndicatorHeight(int indicatorHeight) {
419 | this.indicatorHeight = indicatorHeight;
420 | return this;
421 | }
422 |
423 | public SimpleViewpagerIndicator setShowUnderline(boolean showUnderline, int underlineColor, int underlineHeight) {
424 | this.showUnderline = showUnderline;
425 | this.underlineColor = underlineColor;
426 | this.underlineHeight = underlineHeight;
427 | return this;
428 | }
429 |
430 | public SimpleViewpagerIndicator setShowDivider(boolean showDivider, int dividerColor, int dividerPadding, int dividerWidth) {
431 | this.showDivider = showDivider;
432 | this.dividerColor = dividerColor;
433 | this.dividerPadding = dividerPadding;
434 | this.dividerWidth = dividerWidth;
435 |
436 | return this;
437 | }
438 |
439 | public SimpleViewpagerIndicator setTabTextSize(int tabTextSize) {
440 | this.tabTextSize = tabTextSize;
441 | return this;
442 | }
443 |
444 | public SimpleViewpagerIndicator setTabTextColor(int tabTextColor) {
445 | this.tabTextColor = tabTextColor;
446 | return this;
447 | }
448 |
449 | public SimpleViewpagerIndicator setTabTypeface(@Nullable Typeface tabTypeface) {
450 | this.tabTypeface = tabTypeface;
451 | return this;
452 | }
453 |
454 | public SimpleViewpagerIndicator setTabTypefaceStyle(int tabTypefaceStyle) {
455 | this.tabTypefaceStyle = tabTypefaceStyle;
456 | return this;
457 | }
458 |
459 | public SimpleViewpagerIndicator setTabBackgroundResId(int tabBackgroundResId) {
460 | this.tabBackgroundResId = tabBackgroundResId;
461 | return this;
462 | }
463 |
464 | public SimpleViewpagerIndicator setTabPadding(int tabPadding) {
465 | this.tabPadding = tabPadding;
466 | return this;
467 | }
468 |
469 | public SimpleViewpagerIndicator setSelectedTabTextSize(int selectedTabTextSize) {
470 | this.selectedTabTextSize = selectedTabTextSize;
471 | return this;
472 | }
473 |
474 | public SimpleViewpagerIndicator setSelectedTabTextColor(int selectedTabTextColor) {
475 | this.selectedTabTextColor = selectedTabTextColor;
476 | return this;
477 | }
478 |
479 | public SimpleViewpagerIndicator setSelectedTabTypeface(@Nullable Typeface selectedTabTypeface) {
480 | this.selectedTabTypeface = selectedTabTypeface;
481 | return this;
482 | }
483 |
484 | public SimpleViewpagerIndicator setSelectedTabTypefaceStyle(int selectedTabTypefaceStyle) {
485 | this.selectedTabTypefaceStyle = selectedTabTypefaceStyle;
486 | return this;
487 | }
488 |
489 | public SimpleViewpagerIndicator setScrollOffset(int scrollOffset) {
490 | this.scrollOffset = scrollOffset;
491 | return this;
492 | }
493 | }
--------------------------------------------------------------------------------