├── .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
│ │ │ │ ├── attrs.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── dimens.xml
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── meinv.jpg
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── two.xml
│ │ │ │ ├── one.xml
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── xiaoyuan
│ │ │ ├── Fragment.java
│ │ │ ├── Fragment1.java
│ │ │ ├── MainActivity.java
│ │ │ └── StickyScrollView.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── gao
│ │ │ └── productpage
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── gao
│ │ └── productpage
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── README.md
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | ProductPage
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ProductPage
2 |
3 | ##Android 沉浸式状态栏及悬浮效果
4 |
5 | 
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ProductPage
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoyuanandroid/ProductPage/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.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-xhdpi/meinv.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoyuanandroid/ProductPage/HEAD/app/src/main/res/mipmap-xhdpi/meinv.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoyuanandroid/ProductPage/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoyuanandroid/ProductPage/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoyuanandroid/ProductPage/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoyuanandroid/ProductPage/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaoyuanandroid/ProductPage/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
8 |
--------------------------------------------------------------------------------
/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/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.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/gao/productpage/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.gao.productpage;
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/androidTest/java/com/gao/productpage/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.gao.productpage;
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 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/two.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/one.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
--------------------------------------------------------------------------------
/.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 /Users/gaohequan/Documents/androidsdk/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.3"
6 |
7 | defaultConfig {
8 | applicationId "com.xiaoyuan"
9 | minSdkVersion 14
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.jaeger.statusbaruitl:library:1.3.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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/xiaoyuan/Fragment.java:
--------------------------------------------------------------------------------
1 | package com.xiaoyuan;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | /**
10 | * @author xiaoyuan
11 | */
12 | public class Fragment extends android.support.v4.app.Fragment{
13 | @Override
14 | public void onCreate(@Nullable Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | }
17 |
18 | public static Fragment newInstance() {
19 |
20 | Fragment fragment = new Fragment();
21 | return fragment;
22 | }
23 |
24 | @Nullable
25 | @Override
26 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
27 | return inflater.inflate(R.layout.one,null);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/xiaoyuan/Fragment1.java:
--------------------------------------------------------------------------------
1 | package com.xiaoyuan;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | /**
10 | * @author xiaoyuan
11 | */
12 | public class Fragment1 extends android.support.v4.app.Fragment {
13 |
14 | @Override
15 | public void onCreate(@Nullable Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | }
18 |
19 | public static Fragment1 newInstance() {
20 | Fragment1 fragment = new Fragment1();
21 | return fragment;
22 | }
23 |
24 | @Nullable
25 | @Override
26 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
27 | return inflater.inflate(R.layout.two, null);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/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/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 22sp
6 | 18sp
7 | 15sp
8 | 14sp
9 | 12sp
10 |
11 |
12 | 40dp
13 | 34dp
14 | 24dp
15 | 20dp
16 | 18dp
17 | 14dp
18 | 12dp
19 | 10dp
20 | 8dp
21 | 6dp
22 | 4dp
23 | 2dp
24 |
25 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.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 |
47 |
48 |
49 |
50 | 1.8
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/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/xiaoyuan/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.xiaoyuan;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.View;
7 | import android.view.ViewTreeObserver;
8 | import android.widget.FrameLayout;
9 | import android.widget.LinearLayout;
10 | import android.widget.RelativeLayout;
11 | import android.widget.TextView;
12 |
13 | import com.jaeger.library.StatusBarUtil;
14 |
15 | public class MainActivity extends AppCompatActivity implements View.OnClickListener, StickyScrollView.OnScrollChangedListener {
16 |
17 | TextView oneTextView, twoTextView;
18 | private StickyScrollView stickyScrollView;
19 | private int height;
20 | private LinearLayout llContent;
21 | private RelativeLayout llTitle;
22 | private FrameLayout frameLayout;
23 | private TextView title;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_main);
29 | initView();
30 | initListeners();
31 |
32 | }
33 |
34 | /**
35 | * 初始化View
36 | */
37 | private void initView() {
38 | stickyScrollView = (StickyScrollView) findViewById(R.id.scrollView);
39 | frameLayout = (FrameLayout) findViewById(R.id.tabMainContainer);
40 | title = (TextView) findViewById(R.id.title);
41 | oneTextView = (TextView) findViewById(R.id.infoText);
42 | llContent = (LinearLayout) findViewById(R.id.ll_content);
43 | llTitle = (RelativeLayout) findViewById(R.id.ll_good_detail);
44 | oneTextView.setOnClickListener(this);
45 | twoTextView = (TextView) findViewById(R.id.secondText);
46 | twoTextView.setOnClickListener(this);
47 |
48 | stickyScrollView.setOnScrollListener(this);
49 | StatusBarUtil.setTranslucentForImageView(MainActivity.this, 0, title);
50 | FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) llTitle.getLayoutParams();
51 | params.setMargins(0, getStatusHeight(), 0, 0);
52 | llTitle.setLayoutParams(params);
53 |
54 | //默认设置一个Frg
55 | getSupportFragmentManager().beginTransaction().replace(R.id.tabMainContainer, Fragment.newInstance()).commit();
56 | }
57 |
58 | /**
59 | * 获取状态栏高度
60 | * @return
61 | */
62 | private int getStatusHeight() {
63 | int resourceId = MainActivity.this.getResources().getIdentifier("status_bar_height", "dimen", "android");
64 | return getResources().getDimensionPixelSize(resourceId);
65 |
66 | }
67 |
68 | @Override
69 | public void onClick(View v) {
70 | if (v.getId() == R.id.infoText) {
71 | getSupportFragmentManager().beginTransaction().replace(R.id.tabMainContainer, Fragment.newInstance()).commit();
72 | } else if (v.getId() == R.id.secondText) {
73 | getSupportFragmentManager().beginTransaction().replace(R.id.tabMainContainer, Fragment1.newInstance()).commit();
74 |
75 | }
76 | }
77 |
78 |
79 | private void initListeners() {
80 | //获取内容总高度
81 | final ViewTreeObserver vto = llContent.getViewTreeObserver();
82 | vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
83 | @Override
84 | public void onGlobalLayout() {
85 | height = llContent.getHeight();
86 | //注意要移除
87 | llContent.getViewTreeObserver()
88 | .removeGlobalOnLayoutListener(this);
89 |
90 | }
91 | });
92 |
93 | //获取Fragment高度
94 | ViewTreeObserver viewTreeObserver = frameLayout.getViewTreeObserver();
95 | viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
96 | @Override
97 | public void onGlobalLayout() {
98 | height = height - frameLayout.getHeight();
99 | //注意要移除
100 | frameLayout.getViewTreeObserver()
101 | .removeGlobalOnLayoutListener(this);
102 | }
103 | });
104 |
105 | //获取title高度
106 | ViewTreeObserver viewTreeObserver1 = llTitle.getViewTreeObserver();
107 | viewTreeObserver1.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
108 | @Override
109 | public void onGlobalLayout() {
110 | height = height - llTitle.getHeight() - getStatusHeight();//计算滑动的总距离
111 | stickyScrollView.setStickTop(llTitle.getHeight() + getStatusHeight());//设置距离多少悬浮
112 | //注意要移除
113 | llTitle.getViewTreeObserver()
114 | .removeGlobalOnLayoutListener(this);
115 | }
116 | });
117 |
118 |
119 | }
120 |
121 | @Override
122 | public void onScrollChanged(int l, int t, int oldl, int oldt) {
123 | if (t <= 0) {
124 | llTitle.setBackgroundColor(Color.argb((int) 0, 255, 255, 255));
125 | StatusBarUtil.setTranslucentForImageView(MainActivity.this, 0, title);
126 | } else if (t > 0 && t <= height) {
127 | float scale = (float) t / height;
128 | int alpha = (int) (255 * scale);
129 | llTitle.setBackgroundColor(Color.argb((int) alpha, 227, 29, 26));//设置标题栏的透明度及颜色
130 | StatusBarUtil.setTranslucentForImageView(MainActivity.this, alpha, title);//设置状态栏的透明度
131 | } else {
132 | llTitle.setBackgroundColor(Color.argb((int) 255, 227, 29, 26));
133 | StatusBarUtil.setTranslucentForImageView(MainActivity.this, 255, title);
134 | }
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
11 |
12 |
13 |
19 |
20 |
21 |
26 |
27 |
31 |
32 |
38 |
39 |
44 |
45 |
50 |
55 |
60 |
61 |
66 |
67 |
72 |
73 |
82 |
83 |
92 |
93 |
94 |
95 |
101 |
102 |
103 |
104 |
105 |
106 |
112 |
113 |
121 |
122 |
123 |
131 |
132 |
133 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/app/src/main/java/com/xiaoyuan/StickyScrollView.java:
--------------------------------------------------------------------------------
1 | package com.xiaoyuan;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.drawable.Drawable;
7 | import android.os.Build;
8 | import android.util.AttributeSet;
9 | import android.view.MotionEvent;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.view.animation.AlphaAnimation;
13 | import android.widget.ScrollView;
14 |
15 | import java.util.ArrayList;
16 |
17 | /**
18 | * @author Emil Sj�lander - sjolander.emil@gmail.com
19 | */
20 | public class StickyScrollView extends ScrollView {
21 |
22 | /**
23 | * Tag for views that should stick and have constant drawing. e.g.
24 | * TextViews, ImageViews etc
25 | */
26 | public static final String STICKY_TAG = "sticky";
27 |
28 | /**
29 | * Flag for views that should stick and have non-constant drawing. e.g.
30 | * Buttons, ProgressBars etc
31 | */
32 | public static final String FLAG_NONCONSTANT = "-nonconstant";
33 |
34 | /**
35 | * Flag for views that have aren't fully opaque
36 | */
37 | public static final String FLAG_HASTRANSPARANCY = "-hastransparancy";
38 |
39 | /**
40 | * Default height of the shadow peeking out below the stuck view.
41 | */
42 | private static final int DEFAULT_SHADOW_HEIGHT = 10; // dp;
43 | /**
44 | * XKJ add for add 50dp offset of top
45 | */
46 | private static int MIN_STICK_TOP = 100;// px
47 | // private static final int MIN_STICK_TOP = 0;
48 | private ArrayList stickyViews;
49 | private View currentlyStickingView;
50 | private float stickyViewTopOffset;
51 | private int stickyViewLeftOffset;
52 | private boolean redirectTouchesToStickyView;
53 | private boolean clippingToPadding;
54 | private boolean clipToPaddingHasBeenSet;
55 |
56 | private int mShadowHeight;
57 | private Drawable mShadowDrawable;
58 | private OnScrollChangedListener mOnScrollHandler = null;
59 | private IOnScrollToEnd mOnScrollToEnd = null;
60 |
61 | private final Runnable invalidateRunnable = new Runnable() {
62 |
63 | @Override
64 | public void run() {
65 | if (currentlyStickingView != null) {
66 | int l = getLeftForViewRelativeOnlyChild(currentlyStickingView);
67 | int t = getBottomForViewRelativeOnlyChild(currentlyStickingView);
68 | int r = getRightForViewRelativeOnlyChild(currentlyStickingView);
69 | int b = (int) (getScrollY() + (currentlyStickingView.getHeight() + stickyViewTopOffset));
70 | invalidate(l, t, r, b);
71 | }
72 | postDelayed(this, 16);
73 | }
74 | };
75 |
76 | public StickyScrollView(Context context) {
77 | this(context, null);
78 | }
79 |
80 | public StickyScrollView(Context context, AttributeSet attrs) {
81 | this(context, attrs, android.R.attr.scrollViewStyle);
82 | }
83 |
84 | public StickyScrollView(Context context, AttributeSet attrs, int defStyle) {
85 | super(context, attrs, defStyle);
86 | setup();
87 |
88 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StickyScrollView, defStyle, 0);
89 |
90 | final float density = context.getResources().getDisplayMetrics().density;
91 | int defaultShadowHeightInPix = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
92 |
93 | mShadowHeight = a.getDimensionPixelSize(R.styleable.StickyScrollView_stuckShadowHeight,
94 | defaultShadowHeightInPix);
95 |
96 | int shadowDrawableRes = a.getResourceId(R.styleable.StickyScrollView_stuckShadowDrawable, -1);
97 |
98 | if (shadowDrawableRes != -1) {
99 | mShadowDrawable = context.getResources().getDrawable(shadowDrawableRes);
100 | }
101 |
102 | a.recycle();
103 |
104 | }
105 |
106 | /**
107 | * Sets the height of the shadow drawable in pixels.
108 | *
109 | * @param height
110 | */
111 | public void setShadowHeight(int height) {
112 | mShadowHeight = height;
113 | }
114 |
115 | public void setup() {
116 | stickyViews = new ArrayList();
117 | }
118 |
119 | private int getLeftForViewRelativeOnlyChild(View v) {
120 | int left = v.getLeft();
121 | while (v.getParent() != getChildAt(0)) {
122 | v = (View) v.getParent();
123 | left += v.getLeft();
124 | }
125 | return left;
126 | }
127 |
128 | private int getTopForViewRelativeOnlyChild(View v) {
129 | int top = v.getTop();
130 | while (v.getParent() != getChildAt(0)) {
131 | v = (View) v.getParent();
132 | top += v.getTop();
133 | }
134 | return top;
135 | }
136 |
137 | private int getRightForViewRelativeOnlyChild(View v) {
138 | int right = v.getRight();
139 | while (v.getParent() != getChildAt(0)) {
140 | v = (View) v.getParent();
141 | right += v.getRight();
142 | }
143 | return right;
144 | }
145 |
146 | private int getBottomForViewRelativeOnlyChild(View v) {
147 | int bottom = v.getBottom();
148 | while (v.getParent() != getChildAt(0)) {
149 | v = (View) v.getParent();
150 | bottom += v.getBottom();
151 | }
152 | return bottom;
153 | }
154 |
155 | @Override
156 | protected void onLayout(boolean changed, int l, int t, int r, int b) {
157 | super.onLayout(changed, l, t, r, b);
158 | if (!clipToPaddingHasBeenSet) {
159 | clippingToPadding = true;
160 | }
161 | notifyHierarchyChanged();
162 | }
163 |
164 | @Override
165 | public void setClipToPadding(boolean clipToPadding) {
166 | super.setClipToPadding(clipToPadding);
167 | clippingToPadding = clipToPadding;
168 | clipToPaddingHasBeenSet = true;
169 | }
170 |
171 | @Override
172 | public void addView(View child) {
173 | super.addView(child);
174 | findStickyViews(child);
175 | }
176 |
177 | @Override
178 | public void addView(View child, int index) {
179 | super.addView(child, index);
180 | findStickyViews(child);
181 | }
182 |
183 | @Override
184 | public void addView(View child, int index, android.view.ViewGroup.LayoutParams params) {
185 | super.addView(child, index, params);
186 | findStickyViews(child);
187 | }
188 |
189 | @Override
190 | public void addView(View child, int width, int height) {
191 | super.addView(child, width, height);
192 | findStickyViews(child);
193 | }
194 |
195 | @Override
196 | public void addView(View child, android.view.ViewGroup.LayoutParams params) {
197 | super.addView(child, params);
198 | findStickyViews(child);
199 | }
200 |
201 | @Override
202 | protected void dispatchDraw(Canvas canvas) {
203 | super.dispatchDraw(canvas);
204 | if (currentlyStickingView != null) {
205 | canvas.save();
206 | canvas.translate(getPaddingLeft() + stickyViewLeftOffset, getScrollY() + stickyViewTopOffset
207 | + (clippingToPadding ? getPaddingTop() : 0));
208 |
209 | canvas.clipRect(0, (clippingToPadding ? -stickyViewTopOffset : 0), getWidth() - stickyViewLeftOffset,
210 | currentlyStickingView.getHeight() + mShadowHeight + 1);
211 |
212 | if (mShadowDrawable != null) {
213 | int left = 0;
214 | int right = currentlyStickingView.getWidth();
215 | int top = currentlyStickingView.getHeight();
216 | int bottom = currentlyStickingView.getHeight() + mShadowHeight;
217 | mShadowDrawable.setBounds(left, top, right, bottom);
218 | mShadowDrawable.draw(canvas);
219 | }
220 |
221 | canvas.clipRect(0, (clippingToPadding ? -stickyViewTopOffset : 0), getWidth(),
222 | currentlyStickingView.getHeight());
223 | if (getStringTagForView(currentlyStickingView).contains(FLAG_HASTRANSPARANCY)) {
224 | showView(currentlyStickingView);
225 | currentlyStickingView.draw(canvas);
226 | hideView(currentlyStickingView);
227 | } else {
228 | currentlyStickingView.draw(canvas);
229 | }
230 | canvas.restore();
231 | }
232 | }
233 |
234 | @Override
235 | public boolean dispatchTouchEvent(MotionEvent ev) {
236 | if (ev.getAction() == MotionEvent.ACTION_DOWN) {
237 | redirectTouchesToStickyView = true;
238 | }
239 |
240 | if (redirectTouchesToStickyView) {
241 | redirectTouchesToStickyView = currentlyStickingView != null;
242 | if (redirectTouchesToStickyView) {
243 | redirectTouchesToStickyView = ev.getY() <= (currentlyStickingView.getHeight() + stickyViewTopOffset)
244 | && ev.getX() >= getLeftForViewRelativeOnlyChild(currentlyStickingView)
245 | && ev.getX() <= getRightForViewRelativeOnlyChild(currentlyStickingView);
246 | }
247 | } else if (currentlyStickingView == null) {
248 | redirectTouchesToStickyView = false;
249 | }
250 | if (redirectTouchesToStickyView) {
251 | ev.offsetLocation(0, -1
252 | * ((getScrollY() + stickyViewTopOffset) - getTopForViewRelativeOnlyChild(currentlyStickingView)));
253 |
254 | // XKJ add TODO: remove this
255 | currentlyStickingView.invalidate();
256 | }
257 | return super.dispatchTouchEvent(ev);
258 | }
259 |
260 | private boolean hasNotDoneActionDown = true;
261 |
262 | @Override
263 | public boolean onTouchEvent(MotionEvent ev) {
264 | if (redirectTouchesToStickyView) {
265 | ev.offsetLocation(0,
266 | ((getScrollY() + stickyViewTopOffset) - getTopForViewRelativeOnlyChild(currentlyStickingView)));
267 | }
268 |
269 | if (ev.getAction() == MotionEvent.ACTION_DOWN) {
270 | hasNotDoneActionDown = false;
271 | }
272 |
273 | if (hasNotDoneActionDown) {
274 | MotionEvent down = MotionEvent.obtain(ev);
275 | down.setAction(MotionEvent.ACTION_DOWN);
276 | super.onTouchEvent(down);
277 | hasNotDoneActionDown = false;
278 | }
279 |
280 | if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) {
281 | hasNotDoneActionDown = true;
282 | }
283 |
284 | return super.onTouchEvent(ev);
285 | }
286 |
287 | @Override
288 | protected void onScrollChanged(int l, int t, int oldl, int oldt) {
289 | super.onScrollChanged(l, t, oldl, oldt);
290 | doTheStickyThing();
291 | if (mOnScrollHandler != null) {
292 | mOnScrollHandler.onScrollChanged(l, t, oldl, oldt);
293 | }
294 | int maxScroll = getChildAt(0).getHeight() - getHeight();
295 | if (getChildCount() > 0 && t == maxScroll) {
296 | if (mOnScrollToEnd != null) {
297 | mOnScrollToEnd.onScrollToEnd();
298 | }
299 | }
300 | }
301 |
302 | public void setOnScrollListener(OnScrollChangedListener handler) {
303 | mOnScrollHandler = handler;
304 | }
305 |
306 | public interface OnScrollChangedListener {
307 | public void onScrollChanged(int l, int t, int oldl, int oldt);
308 | }
309 |
310 | public interface IOnScrollToEnd {
311 | public void onScrollToEnd();
312 | }
313 |
314 | public void setOnScrollToEndListener(IOnScrollToEnd handler) {
315 | mOnScrollToEnd = handler;
316 | }
317 |
318 | private void doTheStickyThing() {
319 | View viewThatShouldStick = null;
320 | View approachingView = null;
321 | for (View v : stickyViews) {
322 | int viewTop = getTopForViewRelativeOnlyChild(v) - getScrollY() + (clippingToPadding ? 0 : getPaddingTop())
323 | - MIN_STICK_TOP;// add 50dp
324 |
325 | if (viewTop <= 0) {
326 | if (viewThatShouldStick == null
327 | || viewTop > (getTopForViewRelativeOnlyChild(viewThatShouldStick) - getScrollY() + (clippingToPadding ? 0
328 | : getPaddingTop()))) {
329 | viewThatShouldStick = v;
330 | }
331 | } else {
332 | if (approachingView == null
333 | || viewTop < (getTopForViewRelativeOnlyChild(approachingView) - getScrollY() + (clippingToPadding ? 0
334 | : getPaddingTop()))) {
335 | approachingView = v;
336 | }
337 | }
338 | }
339 | if (viewThatShouldStick != null) {
340 | stickyViewTopOffset = approachingView == null ? MIN_STICK_TOP : Math.min(MIN_STICK_TOP,
341 | getTopForViewRelativeOnlyChild(approachingView) - getScrollY()
342 | + (clippingToPadding ? 0 : getPaddingTop()) - viewThatShouldStick.getHeight());
343 | if (viewThatShouldStick != currentlyStickingView) {
344 | if (currentlyStickingView != null) {
345 | stopStickingCurrentlyStickingView();
346 | }
347 | // only compute the left offset when we start sticking.
348 | stickyViewLeftOffset = getLeftForViewRelativeOnlyChild(viewThatShouldStick);
349 | startStickingView(viewThatShouldStick);
350 | }
351 | } else if (currentlyStickingView != null) {
352 | stopStickingCurrentlyStickingView();
353 | }
354 | }
355 |
356 | private void startStickingView(View viewThatShouldStick) {
357 | currentlyStickingView = viewThatShouldStick;
358 | if (getStringTagForView(currentlyStickingView).contains(FLAG_HASTRANSPARANCY)) {
359 | hideView(currentlyStickingView);
360 | }
361 | if (((String) currentlyStickingView.getTag()).contains(FLAG_NONCONSTANT)) {
362 | post(invalidateRunnable);
363 | }
364 | }
365 |
366 | private void stopStickingCurrentlyStickingView() {
367 | if (getStringTagForView(currentlyStickingView).contains(FLAG_HASTRANSPARANCY)) {
368 | showView(currentlyStickingView);
369 | }
370 | currentlyStickingView = null;
371 | removeCallbacks(invalidateRunnable);
372 | }
373 |
374 | /**
375 | * Notify that the sticky attribute has been added or removed from one or
376 | * more views in the View hierarchy
377 | */
378 | public void notifyStickyAttributeChanged() {
379 | notifyHierarchyChanged();
380 | }
381 |
382 | private void notifyHierarchyChanged() {
383 | if (currentlyStickingView != null) {
384 | stopStickingCurrentlyStickingView();
385 | }
386 | stickyViews.clear();
387 | findStickyViews(getChildAt(0));
388 | doTheStickyThing();
389 | invalidate();
390 | }
391 |
392 | private void findStickyViews(View v) {
393 | if (v instanceof ViewGroup) {
394 | ViewGroup vg = (ViewGroup) v;
395 | for (int i = 0; i < vg.getChildCount(); i++) {
396 | String tag = getStringTagForView(vg.getChildAt(i));
397 | if (tag != null && tag.contains(STICKY_TAG)) {
398 | stickyViews.add(vg.getChildAt(i));
399 | } else if (vg.getChildAt(i) instanceof ViewGroup) {
400 | findStickyViews(vg.getChildAt(i));
401 | }
402 | }
403 | } else {
404 | String tag = (String) v.getTag();
405 | if (tag != null && tag.contains(STICKY_TAG)) {
406 | stickyViews.add(v);
407 | }
408 | }
409 | }
410 |
411 | private String getStringTagForView(View v) {
412 | Object tagObject = v.getTag();
413 | return String.valueOf(tagObject);
414 | }
415 |
416 | private void hideView(View v) {
417 | if (Build.VERSION.SDK_INT >= 11) {
418 | v.setAlpha(0);
419 | } else {
420 | AlphaAnimation anim = new AlphaAnimation(1, 0);
421 | anim.setDuration(0);
422 | anim.setFillAfter(true);
423 | v.startAnimation(anim);
424 | }
425 | }
426 |
427 | private void showView(View v) {
428 | if (Build.VERSION.SDK_INT >= 11) {
429 | v.setAlpha(1);
430 | } else {
431 | AlphaAnimation anim = new AlphaAnimation(0, 1);
432 | anim.setDuration(0);
433 | anim.setFillAfter(true);
434 | v.startAnimation(anim);
435 | }
436 | }
437 |
438 | /**
439 | * 设置悬浮高度
440 | * @param height
441 | */
442 | public void setStickTop(int height) {
443 | MIN_STICK_TOP = height;
444 | }
445 |
446 | /**
447 | * 解决vviewpager在scrollview滑动冲突的问题
448 | */
449 | // 滑动距离及坐标
450 | private float xDistance, yDistance, xLast, yLast;
451 |
452 | @Override
453 | public boolean onInterceptTouchEvent(MotionEvent ev) {
454 | switch (ev.getAction()) {
455 | case MotionEvent.ACTION_DOWN:
456 | xDistance = yDistance = 0f;
457 | xLast = ev.getX();
458 | yLast = ev.getY();
459 | break;
460 | case MotionEvent.ACTION_MOVE:
461 | final float curX = ev.getX();
462 | final float curY = ev.getY();
463 |
464 | xDistance += Math.abs(curX - xLast);
465 | yDistance += Math.abs(curY - yLast);
466 | // com.ihaveu.utils.Log.i("test", "curx:"+curX+",cury:"+curY+",xlast:"+xLast+",ylast:"+yLast);
467 | // xLast = curX;
468 | // yLast = curY;
469 |
470 | if (xDistance > yDistance) {
471 | return false;
472 | }
473 |
474 | }
475 | return super.onInterceptTouchEvent(ev);
476 | }
477 | }
478 |
--------------------------------------------------------------------------------