├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable
│ │ │ │ ├── logo1.png
│ │ │ │ └── bg_white.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── item.xml
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── toxicant
│ │ │ └── hua
│ │ │ └── zuimeitag
│ │ │ ├── MainActivity.java
│ │ │ ├── MyLayoutManager.java
│ │ │ └── TAGRecyclerView.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── toxicant
│ │ │ └── hua
│ │ │ └── zuimeitag
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── toxicant
│ │ └── hua
│ │ └── zuimeitag
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── hello.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | ZuiMeiTAG
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/hello.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huage2580/ZuiMeiTAG/HEAD/hello.gif
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ZuiMeiTAG
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huage2580/ZuiMeiTAG/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logo1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huage2580/ZuiMeiTAG/HEAD/app/src/main/res/drawable/logo1.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huage2580/ZuiMeiTAG/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huage2580/ZuiMeiTAG/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huage2580/ZuiMeiTAG/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huage2580/ZuiMeiTAG/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huage2580/ZuiMeiTAG/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ZuiMeiTAG
2 | 仿最美应用的底栏,使用recyclerView实现,相关博文http://www.jianshu.com/p/7202416974f6
3 | 能不能给个star鼓励下(●'◡'●)
4 | #效果图
5 | 
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_white.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/test/java/com/toxicant/hua/zuimeitag/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.toxicant.hua.zuimeitag;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/toxicant/hua/zuimeitag/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.toxicant.hua.zuimeitag;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\AndroidStudio\SDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.toxicant.hua.zuimeitag"
9 | minSdkVersion 16
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.4.0'
26 | compile 'com.android.support:recyclerview-v7:23.4.0'
27 | }
28 |
--------------------------------------------------------------------------------
/.idea/gradle.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 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/res/layout/item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
14 |
19 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
13 |
14 |
21 |
28 |
29 |
--------------------------------------------------------------------------------
/.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 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/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/com/toxicant/hua/zuimeitag/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.toxicant.hua.zuimeitag;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.graphics.Bitmap;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.util.Log;
10 | import android.view.LayoutInflater;
11 | import android.view.MotionEvent;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.view.animation.Animation;
15 | import android.view.animation.TranslateAnimation;
16 | import android.widget.Button;
17 | import android.widget.ImageView;
18 | import android.widget.LinearLayout;
19 | import android.widget.TextView;
20 | import android.widget.Toast;
21 |
22 | import java.util.ArrayList;
23 |
24 | public class MainActivity extends AppCompatActivity {
25 | TAGRecyclerView rv;
26 | Button btn1;
27 | Button btn2;
28 | ArrayList datas;
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_main);
33 | btn1= (Button) findViewById(R.id.button);
34 | btn2= (Button) findViewById(R.id.button2);
35 | rv= (TAGRecyclerView) findViewById(R.id.rv1);
36 | rv.setLayoutManager(new MyLayoutManager());
37 | datas=new ArrayList<>();
38 | for (int i=0;i<20;i++){
39 | datas.add("item==>"+i);
40 | }
41 | // final int temp=height/7;
42 | final RvAdapter adapter = new RvAdapter();
43 | rv.setAdapter(adapter);
44 | btn1.setOnClickListener(new View.OnClickListener() {
45 | @Override
46 | public void onClick(View v) {
47 | rv.selectNextItem();
48 |
49 | }
50 | });
51 | btn2.setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View v) {
54 | rv.selectPreviousItem();
55 | }
56 | });
57 | rv.setSwitchListener(new TAGRecyclerView.SwitchListener() {
58 | @Override
59 | public void onSwitch(int realIndex) {
60 | Toast.makeText(MainActivity.this,"当前选择=>"+realIndex,Toast.LENGTH_SHORT).show();
61 | }
62 | });
63 | }
64 |
65 | class RvAdapter extends RecyclerView.Adapter{
66 |
67 | @Override
68 | public ViewHoler onCreateViewHolder(ViewGroup parent, int viewType) {
69 | return new ViewHoler(LayoutInflater.from(parent.getContext()).inflate(R.layout.item,null,false));
70 | }
71 |
72 | @Override
73 | public void onBindViewHolder(final ViewHoler holder, int position) {
74 | holder.tv1.setText(datas.get(position));
75 | }
76 |
77 | @Override
78 | public int getItemCount() {
79 | return datas.size();
80 | }
81 |
82 | }
83 | class ViewHoler extends RecyclerView.ViewHolder{
84 | ImageView ivl;
85 | TextView tv1;
86 | LinearLayout ll;
87 | public ViewHoler(View itemView) {
88 | super(itemView);
89 | ivl= (ImageView) itemView.findViewById(R.id.iv);
90 | tv1= (TextView) itemView.findViewById(R.id.tv1);
91 | ll= (LinearLayout) itemView.findViewById(R.id.linear_layout);
92 | itemView.setClickable(false);
93 | }
94 | }
95 |
96 |
97 | }
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/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/java/com/toxicant/hua/zuimeitag/MyLayoutManager.java:
--------------------------------------------------------------------------------
1 | package com.toxicant.hua.zuimeitag;
2 |
3 | import android.graphics.PointF;
4 | import android.graphics.Rect;
5 | import android.support.v7.widget.LinearSmoothScroller;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.util.SparseArray;
8 | import android.util.SparseBooleanArray;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | /**
13 | * Created by hua on 2016.12.10.
14 | */
15 | public class MyLayoutManager extends RecyclerView.LayoutManager {
16 | public int mSelectIndex=0;
17 | final int mPadding=3;
18 | int allWidth=0;
19 | int offsetScroll=0;
20 | int firstView=0;//第一个可视view序号
21 | boolean firstLayout=true;//每次开始布局
22 | //保存所有的Item的上下左右的偏移量信息
23 | private SparseArray allItemFrames = new SparseArray<>();
24 | //记录Item是否出现过屏幕且还没有回收。true表示出现过屏幕上,并且还没被回收
25 | private SparseBooleanArray hasAttachedItems = new SparseBooleanArray();
26 | @Override
27 | public RecyclerView.LayoutParams generateDefaultLayoutParams() {
28 | return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
29 | }
30 |
31 | @Override
32 | public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
33 | detachAndScrapAttachedViews(recycler);
34 | int offsetX=mPadding;
35 | for(int i=0;iallWidth-getWidth()){//最右边
111 | travel=allWidth-getWidth()-offsetScroll;
112 | }
113 | offsetScroll+=travel;
114 | offsetChildrenHorizontal(-travel);
115 | recyclerAndFillItems(recycler, state);
116 | return travel;
117 | }
118 |
119 | void recyclerAndFillItems(RecyclerView.Recycler recycler, RecyclerView.State state){
120 | if (state.isPreLayout()) { // 跳过preLayout,preLayout主要用于支持动画
121 | return;
122 | }
123 |
124 | // 当前scroll offset状态下的显示区域
125 | Rect displayFrame = new Rect(offsetScroll,0, getWidth()+offsetScroll, getHeight());
126 | // Log.e("display","left->"+displayFrame.left+"right->"+displayFrame.right);
127 | //回收
128 | Rect childFrame = new Rect();
129 | for (int i = 0; i < getChildCount(); i++) {
130 | View child = getChildAt(i);
131 | childFrame.left = getDecoratedLeft(child);
132 | childFrame.top = getDecoratedTop(child);
133 | childFrame.right = getDecoratedRight(child);
134 | childFrame.bottom = getDecoratedBottom(child);
135 | // Log.e("回收判断","left->"+childFrame.left+"right->"+childFrame.right);
136 | //如果Item没有在显示区域,就说明需要回收
137 | if (!Rect.intersects(displayFrame, childFrame)) {
138 | //回收掉滑出屏幕的View
139 | removeAndRecycleView(child, recycler);
140 | }
141 | }
142 | //显示
143 | firstLayout=true;
144 | for (int i = 0; i < getItemCount(); i++) {
145 | if (Rect.intersects(displayFrame, allItemFrames.get(i))) {
146 | // Log.e("layout","显示==>"+i);
147 | if(firstLayout){
148 | firstView=i;
149 | firstLayout=false;
150 | }
151 | View scrap = recycler.getViewForPosition(i);
152 | measureChildWithMargins(scrap, 0, 0);
153 | int height = getDecoratedMeasuredHeight(scrap);
154 | if (i!=mSelectIndex){
155 | scrap.setTranslationY(height/7*6);
156 | }
157 | addView(scrap);
158 | Rect frame = allItemFrames.get(i);
159 | // Log.e("显示判断","left->"+frame.left+"right->"+frame.right);
160 | //将这个item布局出来
161 | layoutDecorated(scrap,
162 | frame.left-offsetScroll,
163 | frame.top,
164 | frame.right-offsetScroll,
165 | frame.bottom);
166 |
167 | }
168 | }
169 |
170 | }
171 | }
172 |
173 |
--------------------------------------------------------------------------------
/app/src/main/java/com/toxicant/hua/zuimeitag/TAGRecyclerView.java:
--------------------------------------------------------------------------------
1 | package com.toxicant.hua.zuimeitag;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.content.Context;
6 | import android.support.annotation.Nullable;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.util.AttributeSet;
9 | import android.util.Log;
10 | import android.view.MotionEvent;
11 | import android.view.View;
12 |
13 | /**
14 | * Created by hua on 2016.12.11.
15 | */
16 | public class TAGRecyclerView extends RecyclerView implements View.OnTouchListener {
17 | private int mOffsetIndex;//偏移量,显示的第一个view的序号 [0,n)
18 | private int mSelectIndex;//当前选择的真实序号 [0,n)
19 | private SwitchListener mSwitchListener;
20 |
21 | interface SwitchListener{
22 | void onSwitch(int realIndex);
23 | }
24 | public TAGRecyclerView(Context context) {
25 | super(context);
26 | init();
27 | }
28 |
29 | public TAGRecyclerView(Context context, @Nullable AttributeSet attrs) {
30 | super(context, attrs);
31 | init();
32 | }
33 |
34 | public TAGRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
35 | super(context, attrs, defStyle);
36 | init();
37 | }
38 |
39 | void init(){
40 | mOffsetIndex=0;
41 | mSelectIndex=0;
42 | setOnTouchListener(this);
43 | }
44 |
45 | @Override
46 | public boolean onTouch(View v, MotionEvent event) {
47 | int action = event.getAction();
48 | float x=event.getX();
49 | final int index= (int) (x/(this.getWidth()/7));
50 | //Log.i("index","index->"+index);
51 | switch (action){
52 | case MotionEvent.ACTION_DOWN:
53 | case MotionEvent.ACTION_MOVE:
54 | final int th=this.getHeight()/7;
55 | //view突出
56 | for (int i=0;i<7;i++){
57 | int t=Math.abs(index-i);
58 | // Log.i("突出","点击->"+index+"当前相距->"+t+"第一个view:"+count);
59 | this.getChildAt(i).setTranslationY(t*th);
60 | }
61 | break;
62 | case MotionEvent.ACTION_UP:
63 | //记录位置
64 | RecyclerView.LayoutManager lm= this.getLayoutManager();
65 | if (lm instanceof MyLayoutManager){
66 | mOffsetIndex = ((MyLayoutManager) lm).firstView;
67 | mSelectIndex=mOffsetIndex+index;
68 | ((MyLayoutManager) lm).mSelectIndex=mSelectIndex;
69 | //Log.i("up","抬起相对位置-"+index+"偏移量-"+mOffsetIndex+"选择的真实序号-"+mSelectIndex);
70 | }
71 | if (mSwitchListener!=null){
72 | mSwitchListener.onSwitch(mSelectIndex);
73 | }
74 | boolean isFirstAnim=true;
75 | //下落动画
76 | for (int i=0;i<7;i++){
77 | if (i==index){
78 | continue;
79 | }
80 | View temp=this.getChildAt(i);
81 | ObjectAnimator anim=ObjectAnimator//
82 | .ofFloat(temp, "TranslationY", temp.getTranslationY(),this.getHeight()/7*6)//
83 | .setDuration(500);
84 | anim.start();
85 | if (isFirstAnim){
86 | anim.addListener(new Animator.AnimatorListener() {
87 | @Override
88 | public void onAnimationStart(Animator animation) {
89 |
90 | }
91 |
92 | @Override
93 | public void onAnimationEnd(Animator animation) {
94 | //位移动画
95 | scrollItem(index);
96 | }
97 |
98 | @Override
99 | public void onAnimationCancel(Animator animation) {
100 |
101 | }
102 |
103 | @Override
104 | public void onAnimationRepeat(Animator animation) {
105 |
106 | }
107 | });
108 | isFirstAnim=false;
109 | }
110 |
111 | }
112 |
113 | break;
114 | }
115 | return true;
116 | }
117 |
118 | /**
119 | * 把这个item放到中间,是相对序号
120 | * @param index 对应屏幕上的第几个[0,n)
121 | */
122 | private void scrollItem(int index){
123 | int dx=0;
124 | final int tw=TAGRecyclerView.this.getWidth()/7;
125 | if (index<3){
126 | dx=-tw*(3-index);
127 | }else if(index>3){
128 | dx=tw*(index-3);
129 | }
130 | TAGRecyclerView.this.smoothScrollBy(dx,0);
131 | }
132 |
133 | /**
134 | * 切换到下一个item
135 | */
136 | public boolean selectNextItem(){
137 | if (mSelectIndex>=TAGRecyclerView.this.getAdapter().getItemCount()-1){//已经是最后一个
138 | return false;
139 | }
140 | //当前选择的item下落
141 | final RecyclerView.LayoutManager lm= this.getLayoutManager();
142 | if (lm instanceof MyLayoutManager) {
143 | mOffsetIndex = ((MyLayoutManager) lm).firstView;
144 | View view=this.getChildAt(mSelectIndex-mOffsetIndex);
145 | final ObjectAnimator anim=ObjectAnimator.ofFloat(view, "TranslationY", view.getTranslationY(),this.getHeight()/7*6)
146 | .setDuration(200);
147 | anim.start();
148 | anim.addListener(new Animator.AnimatorListener() {
149 | @Override
150 | public void onAnimationStart(Animator animation) {
151 |
152 | }
153 |
154 | @Override
155 | public void onAnimationEnd(Animator animation) {
156 | //下一个item升起
157 | mSelectIndex+=1;
158 | ((MyLayoutManager) lm).mSelectIndex=mSelectIndex;
159 | View view=TAGRecyclerView.this.getChildAt(mSelectIndex-mOffsetIndex);
160 | ObjectAnimator animR=ObjectAnimator.ofFloat(view, "TranslationY", view.getTranslationY(),0)
161 | .setDuration(200);
162 | animR.start();
163 | animR.addListener(new Animator.AnimatorListener() {
164 | @Override
165 | public void onAnimationStart(Animator animation) {
166 |
167 | }
168 |
169 | @Override
170 | public void onAnimationEnd(Animator animation) {
171 | scrollItem(mSelectIndex-mOffsetIndex);
172 | }
173 |
174 | @Override
175 | public void onAnimationCancel(Animator animation) {
176 |
177 | }
178 |
179 | @Override
180 | public void onAnimationRepeat(Animator animation) {
181 |
182 | }
183 | });
184 | }
185 |
186 | @Override
187 | public void onAnimationCancel(Animator animation) {
188 |
189 | }
190 |
191 | @Override
192 | public void onAnimationRepeat(Animator animation) {
193 |
194 | }
195 | });
196 | }
197 | return true;
198 | }
199 |
200 | /**
201 | * 切换到上一个item
202 | */
203 | public boolean selectPreviousItem(){
204 | if (mSelectIndex<1){//已经是第一个
205 | return false;
206 | }
207 | //当前选择的item下落
208 | final RecyclerView.LayoutManager lm= this.getLayoutManager();
209 | if (lm instanceof MyLayoutManager) {
210 | mOffsetIndex = ((MyLayoutManager) lm).firstView;
211 | View view=this.getChildAt(mSelectIndex-mOffsetIndex);
212 | final ObjectAnimator anim=ObjectAnimator.ofFloat(view, "TranslationY", view.getTranslationY(),this.getHeight()/7*6)
213 | .setDuration(200);
214 | anim.start();
215 | anim.addListener(new Animator.AnimatorListener() {
216 | @Override
217 | public void onAnimationStart(Animator animation) {
218 |
219 | }
220 |
221 | @Override
222 | public void onAnimationEnd(Animator animation) {
223 | //上一个item升起
224 | mSelectIndex-=1;
225 | ((MyLayoutManager) lm).mSelectIndex=mSelectIndex;
226 | View view=TAGRecyclerView.this.getChildAt(mSelectIndex-mOffsetIndex);
227 | ObjectAnimator animR=ObjectAnimator.ofFloat(view, "TranslationY", view.getTranslationY(),0)
228 | .setDuration(200);
229 | animR.start();
230 | animR.addListener(new Animator.AnimatorListener() {
231 | @Override
232 | public void onAnimationStart(Animator animation) {
233 |
234 | }
235 |
236 | @Override
237 | public void onAnimationEnd(Animator animation) {
238 | scrollItem(mSelectIndex-mOffsetIndex);
239 | }
240 |
241 | @Override
242 | public void onAnimationCancel(Animator animation) {
243 |
244 | }
245 |
246 | @Override
247 | public void onAnimationRepeat(Animator animation) {
248 |
249 | }
250 | });
251 | }
252 |
253 | @Override
254 | public void onAnimationCancel(Animator animation) {
255 |
256 | }
257 |
258 | @Override
259 | public void onAnimationRepeat(Animator animation) {
260 |
261 | }
262 | });
263 | }
264 | return true;
265 |
266 | }
267 |
268 | /**
269 | * 当前选择的item真实序号
270 | * @return
271 | */
272 | public int getSelectIndex(){
273 | return mSelectIndex;
274 | }
275 | public void setSwitchListener(SwitchListener listener){
276 | this.mSwitchListener=listener;
277 | }
278 | }
279 |
--------------------------------------------------------------------------------