├── .gitignore
├── README.md
├── Screenshot
├── .gitignore
├── .idea
│ ├── compiler.xml
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── gradle.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── runConfigurations.xml
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── screenshot
│ │ │ ├── MainActivity.java
│ │ │ └── Shot1_Activity.java
│ │ └── res
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── activity_shot1.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ ├── bg_shottest.jpg
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
└── TranslucentScrollView
├── .gitignore
├── .idea
├── caches
│ ├── build_file_checksums.ser
│ └── gradle_models.ser
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dbnavigator.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── milo
│ │ └── demo
│ │ ├── MainActivity.java
│ │ ├── base
│ │ └── BaseActivity.java
│ │ ├── impl
│ │ └── ActionBarClickListener.java
│ │ ├── ui
│ │ ├── FirstDemoActivity.java
│ │ └── SecondDemoActivity.java
│ │ ├── utils
│ │ └── SystemBarUtils.java
│ │ └── widget
│ │ └── TranslucentActionBar.java
│ └── res
│ ├── layout
│ ├── actionbar_trans.xml
│ ├── activity_actionbar.xml
│ ├── activity_demo_first.xml
│ ├── activity_demo_second.xml
│ ├── activity_main.xml
│ ├── view_header.xml
│ └── view_normal.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ ├── bg_avatar.png
│ ├── bg_banner_my.png
│ ├── dft_avatar.png
│ ├── ic_address.png
│ ├── ic_agent_my.png
│ ├── ic_consume_history.png
│ ├── ic_invite_my.png
│ ├── ic_launcher.png
│ ├── ic_left_light.png
│ ├── ic_luck_my.png
│ ├── ic_right_gray.png
│ ├── ic_set_my.png
│ ├── ic_shopcar_my.png
│ ├── ic_sign.png
│ ├── ic_teacher_my.png
│ └── ic_wallet.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-v19
│ └── styles.xml
│ ├── values-v21
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── ids.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── config.gradle
├── gif
└── device-2016-12-26-192438.gif
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── mylib
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── milo
│ │ └── lib
│ │ ├── PullZoomView.java
│ │ ├── TranslucentScrollView.java
│ │ ├── impl
│ │ └── IZoomControl.java
│ │ └── utils
│ │ ├── SizeUtils.java
│ │ └── StatusBarUtils.java
│ └── res
│ ├── layout
│ └── milo_zoomview.xml
│ └── values
│ ├── colors.xml
│ └── strings.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/libraries
40 |
41 | # Keystore files
42 | *.jks
43 |
44 | # External native build folder generated in Android Studio 2.2 and later
45 | .externalNativeBuild
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## TranslucentScrollView
2 |
3 | 效果如图:
4 | 
5 |
6 | 用法请参见
7 | [Demo](https://github.com/yanjunhui2014/TranslucentScrollView/blob/master/TranslucentScrollView/app/src/main/java/com/milo/demo/ui/SecondDemoActivity.java)
8 |
9 | 主要API
10 |
11 | ```
12 | //设置HeaderView(也就是拉伸区域)
13 | PullZoomView.setHeaderView(R.layout.view_header);
14 | //设置普通(追加)视图,可以添加多个
15 | PullZoomView.addNormalView(R.layout.view_normal, R.layout.view_normal);
16 | //设置阻力系数
17 | PullZoomView.setDamping(0.2f, 0);
18 |
19 | //关联渐变视图 - 可选
20 | PullZoomView.attachTransView(mActionBar, getResources().getColor(R.color.colorPrimary), -1, -1);
21 | //设置透明度变化监听 - 可选
22 | PullZoomView.setTranslucentChangedListener(new TranslucentScrollView.TranslucentChangedListener() {
23 | @Override
24 | public void onTranslucentChanged(int transAlpha) {
25 | //回调alpah值,0-255
26 | }
27 | });
28 | //隐藏ScrollBar - 可选
29 | PullZoomView.mLayoutTransSV.setVerticalScrollBarEnabled(false);
30 | ```
31 |
--------------------------------------------------------------------------------
/Screenshot/.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 |
--------------------------------------------------------------------------------
/Screenshot/.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 |
--------------------------------------------------------------------------------
/Screenshot/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Screenshot/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/Screenshot/.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 |
--------------------------------------------------------------------------------
/Screenshot/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Screenshot/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Screenshot/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Screenshot/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.1"
6 | defaultConfig {
7 | applicationId "com.screenshot"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.0.1'
28 | testCompile 'junit:junit:4.12'
29 | }
30 |
--------------------------------------------------------------------------------
/Screenshot/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:\02-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 |
--------------------------------------------------------------------------------
/Screenshot/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Screenshot/app/src/main/java/com/screenshot/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.screenshot;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.widget.Button;
7 |
8 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
9 |
10 | Button btnShot1;
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 | setContentView(R.layout.activity_main);
16 | init();
17 | }
18 |
19 | private void init() {
20 | btnShot1 = (Button) findViewById(R.id.btn_shot_1);
21 | btnShot1.setOnClickListener(this);
22 | }
23 |
24 | @Override
25 | public void onClick(View view) {
26 | switch (view.getId()) {
27 | case R.id.btn_shot_1:
28 | startActivity(Shot1_Activity.createIntent(this));
29 | break;
30 | }
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/Screenshot/app/src/main/java/com/screenshot/Shot1_Activity.java:
--------------------------------------------------------------------------------
1 | package com.screenshot;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.graphics.Bitmap;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.ImageView;
12 |
13 | import java.io.FileOutputStream;
14 | import java.text.SimpleDateFormat;
15 | import java.util.Date;
16 | import java.util.Locale;
17 |
18 | /**
19 | * Created by 晖仔(Milo) on 2017/1/6.
20 | * email:303767416@qq.com
21 | */
22 |
23 | public class Shot1_Activity extends AppCompatActivity implements View.OnClickListener {
24 |
25 | Button btnShot;
26 | ImageView shotView;
27 |
28 | public static Intent createIntent(Context context) {
29 | Intent intent = new Intent(context, Shot1_Activity.class);
30 | return intent;
31 | }
32 |
33 | @Override
34 | protected void onCreate(@Nullable Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_shot1);
37 | init();
38 |
39 | }
40 |
41 | private void init() {
42 | btnShot = (Button) findViewById(R.id.btn_shot);
43 | btnShot.setOnClickListener(this);
44 |
45 | shotView = (ImageView) findViewById(R.id.img_shot);
46 | }
47 |
48 | @Override
49 | public void onClick(View v) {
50 | switch (v.getId()) {
51 | case R.id.btn_shot:
52 | shot(shotView);
53 | break;
54 | }
55 | }
56 |
57 | private void shot(View shotView) {
58 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.US);
59 | String fname = "/sdcard/" + sdf.format(new Date()) + ".png";
60 | shotView.setDrawingCacheEnabled(true);
61 | shotView.buildDrawingCache();
62 | Bitmap bitmap = shotView.getDrawingCache();
63 |
64 | if (bitmap != null) {
65 | System.out.println("bitmap got !");
66 |
67 | try {
68 | FileOutputStream out = new FileOutputStream(fname);
69 | bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
70 | System.out.println("file " + fname + "output done.");
71 | } catch (Exception e) {
72 | e.printStackTrace();
73 | }
74 | } else {
75 | System.out.println("bitmap is NULL !");
76 | }
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
18 |
19 |
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/layout/activity_shot1.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/Screenshot/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/Screenshot/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/Screenshot/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/mipmap-xxhdpi/bg_shottest.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/Screenshot/app/src/main/res/mipmap-xxhdpi/bg_shottest.jpg
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/Screenshot/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/Screenshot/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Screenshot
3 |
4 |
--------------------------------------------------------------------------------
/Screenshot/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Screenshot/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/Screenshot/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 |
--------------------------------------------------------------------------------
/Screenshot/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/Screenshot/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Screenshot/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/Screenshot/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 |
--------------------------------------------------------------------------------
/Screenshot/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 |
--------------------------------------------------------------------------------
/Screenshot/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/TranslucentScrollView/.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 |
--------------------------------------------------------------------------------
/TranslucentScrollView/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/TranslucentScrollView/.idea/caches/gradle_models.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/.idea/caches/gradle_models.ser
--------------------------------------------------------------------------------
/TranslucentScrollView/.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 |
--------------------------------------------------------------------------------
/TranslucentScrollView/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/TranslucentScrollView/.idea/dbnavigator.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 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
--------------------------------------------------------------------------------
/TranslucentScrollView/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/TranslucentScrollView/.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 |
--------------------------------------------------------------------------------
/TranslucentScrollView/.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 |
--------------------------------------------------------------------------------
/TranslucentScrollView/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/TranslucentScrollView/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/TranslucentScrollView/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | def ext = rootProject.ext
5 | compileSdkVersion ext.compileSdkVersion
6 | buildToolsVersion ext.buildToolsVersion
7 |
8 | defaultConfig {
9 | minSdkVersion ext.minSdkVersion
10 | targetSdkVersion ext.targetSdkVersion
11 | applicationId "com.milo.demo"
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | Map manifestPlaceholders = null
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | implementation 'androidx.appcompat:appcompat:1.1.0'
28 |
29 | implementation project(':mylib')
30 | }
31 |
--------------------------------------------------------------------------------
/TranslucentScrollView/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:\02-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 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
24 |
25 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/java/com/milo/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.milo.demo;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.Button;
6 |
7 | import androidx.annotation.Nullable;
8 |
9 | import com.milo.demo.base.BaseActivity;
10 | import com.milo.demo.ui.FirstDemoActivity;
11 | import com.milo.demo.ui.SecondDemoActivity;
12 |
13 | /**
14 | * Created by Administrator on 2016/12/16.
15 | * email:303767416@qq.com
16 | */
17 |
18 | public class MainActivity extends BaseActivity implements View.OnClickListener {
19 |
20 | private Button mBtnFirst;
21 | private Button mBtnSecond;
22 |
23 | @Override
24 | protected void onCreate(@Nullable Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_main);
27 | initView();
28 | }
29 |
30 | @Override
31 | public void onClick(View v) {
32 | if (v == mBtnFirst) {
33 | startActivity(FirstDemoActivity.createIntent(this));
34 | } else if (v == mBtnSecond) {
35 | startActivity(SecondDemoActivity.createIntent(this));
36 | }
37 | }
38 |
39 | private void initView() {
40 | mBtnFirst = (Button) findViewById(R.id.mBtnFirst);
41 | mBtnFirst.setOnClickListener(this);
42 | mBtnSecond = (Button) findViewById(R.id.mBtnSecond);
43 | mBtnSecond.setOnClickListener(this);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/java/com/milo/demo/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.milo.demo.base;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.annotation.Nullable;
6 | import androidx.appcompat.app.AppCompatActivity;
7 |
8 | /**
9 | * Created by 晖仔(Milo) on 2017/2/13.
10 | * email:303767416@qq.com
11 | */
12 |
13 | public abstract class BaseActivity extends AppCompatActivity {
14 | public String TAG = "BaseActivity";
15 |
16 | @Override
17 | protected void onCreate(@Nullable Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | TAG = getClass().getName();
20 | }
21 |
22 | /**
23 | * 获取状态栏高度
24 | *
25 | * @return
26 | */
27 | public int getStatusBarHeight() {
28 | //获取status_bar_height资源的ID
29 | int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
30 | if (resourceId > 0) {
31 | //根据资源ID获取响应的尺寸值
32 | return getResources().getDimensionPixelSize(resourceId);
33 | }
34 | return 0;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/java/com/milo/demo/impl/ActionBarClickListener.java:
--------------------------------------------------------------------------------
1 | package com.milo.demo.impl;
2 |
3 | /**
4 | * [ActionBar点击监听器]
5 | * Created by yanjunhui
6 | * on 2016/8/17.
7 | * email:303767416@qq.com
8 | */
9 | public interface ActionBarClickListener {
10 |
11 | void onLeftClick();
12 |
13 | void onRightClick();
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/java/com/milo/demo/ui/FirstDemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.milo.demo.ui;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 |
8 | import androidx.annotation.Nullable;
9 |
10 | import com.milo.demo.R;
11 | import com.milo.demo.base.BaseActivity;
12 | import com.milo.demo.impl.ActionBarClickListener;
13 | import com.milo.demo.utils.SystemBarUtils;
14 | import com.milo.demo.widget.TranslucentActionBar;
15 | import com.milo.lib.TranslucentScrollView;
16 |
17 | public class FirstDemoActivity extends BaseActivity implements ActionBarClickListener, TranslucentScrollView.TranslucentChangedListener {
18 |
19 | private TranslucentScrollView translucentScrollView;
20 | private TranslucentActionBar actionBar;
21 | private View zoomView;
22 |
23 | public static Intent createIntent(Context context) {
24 | return new Intent(context, FirstDemoActivity.class);
25 | }
26 |
27 | @Override
28 | protected void onCreate(@Nullable Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_demo_first);
31 |
32 | init();
33 | SystemBarUtils.immersiveStatusBar(this);
34 | }
35 |
36 | private void init() {
37 | actionBar = (TranslucentActionBar) findViewById(R.id.actionbar);
38 | //初始actionBar
39 | actionBar.setData("测试", 0, null, 0, null, null);
40 | //开启渐变
41 | actionBar.setNeedTranslucent();
42 | //设置状态栏高度
43 | actionBar.setStatusBarHeight(getStatusBarHeight());
44 |
45 | translucentScrollView = (TranslucentScrollView) findViewById(R.id.pullzoom_scrollview);
46 | //设置透明度变化监听
47 | translucentScrollView.setTranslucentChangedListener(this);
48 | //关联需要渐变的视图
49 | translucentScrollView.setTransView(actionBar);
50 | //设置ActionBar键渐变颜色
51 | translucentScrollView.setTransColor(getResources().getColor(R.color.orange_dft));
52 |
53 | zoomView = findViewById(R.id.lay_header);
54 | //关联伸缩的视图
55 | translucentScrollView.setPullZoomView(zoomView);
56 | }
57 |
58 | @Override
59 | public void onLeftClick() {
60 |
61 | }
62 |
63 | @Override
64 | public void onRightClick() {
65 |
66 | }
67 |
68 | @Override
69 | public void onTranslucentChanged(int transAlpha) {
70 | actionBar.tvTitle.setVisibility(transAlpha > 48 ? View.VISIBLE : View.GONE);
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/java/com/milo/demo/ui/SecondDemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.milo.demo.ui;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import androidx.annotation.Nullable;
11 |
12 | import com.milo.demo.R;
13 | import com.milo.demo.base.BaseActivity;
14 | import com.milo.demo.utils.SystemBarUtils;
15 | import com.milo.lib.PullZoomView;
16 | import com.milo.lib.TranslucentScrollView;
17 |
18 | /**
19 | * 标题:Demo-二
20 | * 功能:
21 | * 备注:更简洁易用(推荐)
22 | *
23 | * Created by Milo 2020/3/3
24 | * E-Mail : 303767416@qq.com
25 | */
26 | public class SecondDemoActivity extends BaseActivity {
27 |
28 | private PullZoomView mPullZoomView;
29 | private ViewGroup mActionBar;
30 | private View mStatusBarHolder;
31 | private TextView mTvTitle;
32 |
33 | public static Intent createIntent(Context context) {
34 | return new Intent(context, SecondDemoActivity.class);
35 | }
36 |
37 | @Override
38 | protected void onCreate(@Nullable Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.activity_demo_second);
41 | initView();
42 | SystemBarUtils.immersiveStatusBar(this);
43 | }
44 |
45 | private void initView() {
46 | mPullZoomView = (PullZoomView) findViewById(R.id.mPullZoomView);
47 | mActionBar = findViewById(R.id.mActionBar);
48 | mStatusBarHolder = findViewById(R.id.mStatusBarHolder);
49 | mTvTitle = findViewById(R.id.mTvTitle);
50 |
51 | mPullZoomView.setHeaderView(R.layout.view_header);
52 | mPullZoomView.addNormalView(R.layout.view_normal, R.layout.view_normal);//可以连续添加多个
53 | mPullZoomView.setDamping(0.2f, 0);
54 |
55 | ViewGroup.LayoutParams params = mStatusBarHolder.getLayoutParams();
56 | params.height += SystemBarUtils.getStatusBarHeight(this);
57 | mStatusBarHolder.setLayoutParams(params);
58 |
59 | mTvTitle.setVisibility(View.GONE);
60 | mPullZoomView.attachTransView(mActionBar, getResources().getColor(R.color.colorPrimary), -1, -1);
61 | mPullZoomView.setTranslucentChangedListener(new TranslucentScrollView.TranslucentChangedListener() {
62 | @Override
63 | public void onTranslucentChanged(int transAlpha) {
64 | mTvTitle.setVisibility(transAlpha > 48 ? View.VISIBLE : View.GONE);
65 | }
66 | });
67 | mPullZoomView.mLayoutTransSV.setVerticalScrollBarEnabled(false);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/java/com/milo/demo/utils/SystemBarUtils.java:
--------------------------------------------------------------------------------
1 | package com.milo.demo.utils;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.Activity;
5 | import android.content.Context;
6 | import android.graphics.Color;
7 | import android.os.Build;
8 | import android.util.Log;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.view.Window;
12 | import android.view.WindowManager;
13 | import android.widget.FrameLayout;
14 |
15 | import androidx.annotation.ColorInt;
16 | import androidx.annotation.FloatRange;
17 | import androidx.core.view.ViewCompat;
18 |
19 | import com.milo.demo.R;
20 |
21 | import java.lang.reflect.Field;
22 | import java.lang.reflect.Method;
23 | import java.util.regex.Pattern;
24 |
25 | /**
26 | * 状态栏工具类
27 | * 状态栏两种模式(Android 4.4以上)
28 | * 1.沉浸式全屏模式
29 | * 2.状态栏着色模式
30 | */
31 | public class SystemBarUtils {
32 | private static float DEFAULT_ALPHA = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? 0.2f : 0.3f;
33 |
34 |
35 | /**
36 | * Android4.4以上的沉浸式全屏模式
37 | * 注:
38 | * 1.删除fitsSystemWindows属性:Android5.0以上使用该方法如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性
39 | * 或者调用forceFitsSystemWindows方法
40 | * 2.不删除fitsSystemWindows属性:也可以区别处理,Android5.0以上使用自己的方式实现,不调用该方法
41 | *
42 | * @param activity Activity对象
43 | */
44 | public static void immersiveStatusBar(Activity activity) {
45 | immersiveStatusBar(activity, DEFAULT_ALPHA);
46 | }
47 |
48 | /**
49 | * Android4.4以上的沉浸式全屏模式
50 | * 注:
51 | * 1.删除fitsSystemWindows属性:Android5.0以上使用该方法如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性
52 | * 或者调用forceFitsSystemWindows方法
53 | * 2.不删除fitsSystemWindows属性:也可以区别处理,Android5.0以上使用自己的方式实现,不调用该方法
54 | *
55 | * @param activity Activity对象
56 | * @param alpha 透明栏透明度[0.0-1.0]
57 | */
58 | public static void immersiveStatusBar(Activity activity, @FloatRange(from = 0.0, to = 1.0) float alpha) {
59 | immersiveStatusBar(activity.getWindow(), alpha);
60 | }
61 |
62 | /**
63 | * Android4.4以上的沉浸式全屏模式
64 | * 注:
65 | * 1.删除fitsSystemWindows属性:Android5.0以上使用该方法如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性
66 | * 或者调用forceFitsSystemWindows方法
67 | * 2.不删除fitsSystemWindows属性:也可以区别处理,Android5.0以上使用自己的方式实现,不调用该方法
68 | *
69 | * @param window 一般都是用于Activity的window,也可以是其他的例如Dialog,DialogFragment
70 | */
71 | public static void immersiveStatusBar(Window window) {
72 | immersiveStatusBar(window, DEFAULT_ALPHA);
73 | }
74 |
75 | /**
76 | * Android4.4以上的沉浸式全屏模式
77 | * 注:
78 | * 1.删除fitsSystemWindows属性:Android5.0以上使用该方法如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性
79 | * 或者调用forceFitsSystemWindows方法
80 | * 2.不删除fitsSystemWindows属性:也可以区别处理,Android5.0以上使用自己的方式实现,不调用该方法
81 | *
82 | * @param window 一般都是用于Activity的window,也可以是其他的例如Dialog,DialogFragment
83 | * @param alpha 透明栏透明度[0.0-1.0]
84 | */
85 | public static void immersiveStatusBar(Window window, @FloatRange(from = 0.0, to = 1.0) float alpha) {
86 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
87 | return;
88 | }
89 |
90 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
91 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
92 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
93 | window.setStatusBarColor(Color.TRANSPARENT);
94 |
95 | int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
96 | systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
97 | systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
98 | window.getDecorView().setSystemUiVisibility(systemUiVisibility);
99 | } else {
100 | window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
101 | }
102 |
103 | ViewGroup decorView = (ViewGroup) window.getDecorView();
104 | ViewGroup contentView = (ViewGroup) window.getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
105 | View rootView = contentView.getChildAt(0);
106 | int statusBarHeight = getStatusBarHeight(window.getContext());
107 | if (rootView != null) {
108 | FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) rootView.getLayoutParams();
109 | ViewCompat.setFitsSystemWindows(rootView, true);
110 | lp.topMargin = -statusBarHeight;
111 | rootView.setLayoutParams(lp);
112 | }
113 |
114 | setTranslucentView(decorView, alpha);
115 | }
116 |
117 | /**
118 | * 设置状态栏darkMode,字体颜色及icon变黑(目前支持MIUI6以上,Flyme4以上,Android M以上)
119 | */
120 | public static void setStatusBarDarkMode(Activity activity) {
121 | setStatusBarDarkMode(activity.getWindow());
122 | }
123 |
124 | /**
125 | * 设置状态栏lightMode,字体颜色及icon变白(目前支持MIUI6以上,Flyme4以上,Android M以上)
126 | */
127 | public static void setStatusBarLightMode(Activity activity) {
128 | setStatusBarLightMode(activity.getWindow());
129 | }
130 |
131 | /**
132 | * 设置状态栏darkMode,字体颜色及icon变黑(目前支持MIUI6以上,Flyme4以上,Android M以上)
133 | */
134 | public static void setStatusBarDarkMode(Window window) {
135 | if (isFlyme4Later()) {
136 | setStatusBarDarkModeForFlyme4(window, true);
137 | } else if (isMIUI6Later() && !isDevMIUI()) {
138 | setStatusBarDarkModeForMIUI6(window, true);
139 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
140 | setStatusBarDarkModeForM(window);
141 | }
142 | }
143 |
144 | /**
145 | * 设置状态栏lightMode,字体颜色及icon变白(目前支持MIUI6以上,Flyme4以上,Android M以上)
146 | */
147 | public static void setStatusBarLightMode(Window window) {
148 | if (isFlyme4Later()) {
149 | setStatusBarDarkModeForFlyme4(window, false);
150 | } else if (isMIUI6Later()) {
151 | setStatusBarDarkModeForMIUI6(window, false);
152 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
153 | setStatusBarDarkModeForM(window, false);
154 | }
155 | }
156 |
157 | /**
158 | * android 6.0设置字体颜色
159 | */
160 | @TargetApi(Build.VERSION_CODES.M)
161 | public static void setStatusBarDarkModeForM(Window window) {
162 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
163 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
164 | window.setStatusBarColor(Color.TRANSPARENT);
165 |
166 | int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
167 | systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
168 | window.getDecorView().setSystemUiVisibility(systemUiVisibility);
169 | }
170 |
171 | /**
172 | * android 6.0设置字体颜色 可控制深色或浅色
173 | */
174 | @TargetApi(Build.VERSION_CODES.M)
175 | public static void setStatusBarDarkModeForM(Window window, boolean dark) {
176 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
177 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
178 | window.setStatusBarColor(Color.TRANSPARENT);
179 |
180 | int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
181 | if (dark) {
182 | systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
183 | } else {
184 | systemUiVisibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
185 | }
186 | window.getDecorView().setSystemUiVisibility(systemUiVisibility);
187 | }
188 |
189 | /**
190 | * 设置Flyme4+的darkMode,darkMode时候字体颜色及icon变黑
191 | * http://open-wiki.flyme.cn/index.php?title=Flyme%E7%B3%BB%E7%BB%9FAPI
192 | */
193 | public static boolean setStatusBarDarkModeForFlyme4(Window window, boolean dark) {
194 | boolean result = false;
195 | if (window != null) {
196 | try {
197 | WindowManager.LayoutParams e = window.getAttributes();
198 | Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
199 | Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
200 | darkFlag.setAccessible(true);
201 | meizuFlags.setAccessible(true);
202 | int bit = darkFlag.getInt(null);
203 | int value = meizuFlags.getInt(e);
204 | if (dark) {
205 | value |= bit;
206 | } else {
207 | value &= ~bit;
208 | }
209 |
210 | meizuFlags.setInt(e, value);
211 | window.setAttributes(e);
212 | result = true;
213 | } catch (Exception var8) {
214 | Log.e("StatusBar", "setStatusBarDarkIcon: failed");
215 | }
216 | }
217 |
218 | return result;
219 | }
220 |
221 | /**
222 | * 设置MIUI6+的状态栏是否为darkMode,darkMode时候字体颜色及icon变黑
223 | * http://dev.xiaomi.com/doc/p=4769/
224 | */
225 | public static void setStatusBarDarkModeForMIUI6(Window window, boolean darkmode) {
226 | Class extends Window> clazz = window.getClass();
227 | try {
228 | int darkModeFlag = 0;
229 | Class> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
230 | Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
231 | darkModeFlag = field.getInt(layoutParams);
232 | Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
233 | extraFlagField.invoke(window, darkmode ? darkModeFlag : 0, darkModeFlag);
234 | } catch (Exception e) {
235 | e.printStackTrace();
236 | }
237 | }
238 |
239 | /**
240 | * 创建假的状态栏View
241 | */
242 | private static void setStatusBar(ViewGroup container, @ColorInt int statusBarColor, boolean visible, boolean addToFirst) {
243 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
244 | View statusBarView = container.findViewById(R.id.statusbar_view);
245 | if (statusBarView == null) {
246 | statusBarView = new View(container.getContext());
247 | statusBarView.setId(R.id.statusbar_view);
248 | ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(
249 | ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(container.getContext()));
250 | if (addToFirst) {
251 | container.addView(statusBarView, 0, lp);
252 | } else {
253 | container.addView(statusBarView, lp);
254 | }
255 | }
256 |
257 | statusBarView.setBackgroundColor(statusBarColor);
258 | statusBarView.setVisibility(visible ? View.VISIBLE : View.GONE);
259 | }
260 | }
261 |
262 | /**
263 | * 创建假的状态栏View
264 | */
265 | private static void setStatusBar(ViewGroup container, @ColorInt int statusBarColor, boolean visible) {
266 | setStatusBar(container, statusBarColor, visible, false);
267 | }
268 |
269 | /**
270 | * 创建假的透明栏
271 | */
272 | private static void setTranslucentView(ViewGroup container,
273 | @FloatRange(from = 0.0, to = 1.0) float alpha) {
274 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
275 | View translucentView = container.findViewById(R.id.translucent_view);
276 | if (translucentView == null) {
277 | translucentView = new View(container.getContext());
278 | translucentView.setId(R.id.translucent_view);
279 | ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(
280 | ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(container.getContext()));
281 | container.addView(translucentView, lp);
282 | }
283 |
284 | translucentView.setBackgroundColor(Color.argb((int) (alpha * 255), 0, 0, 0));
285 | }
286 | }
287 |
288 |
289 | /**
290 | * 获取状态栏高度
291 | */
292 | public static int getStatusBarHeight(Context context) {
293 | int result = 0;
294 | int resId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
295 | if (resId > 0) {
296 | result = context.getResources().getDimensionPixelSize(resId);
297 | }
298 | return result;
299 | }
300 |
301 | /**
302 | * 判断是否Flyme4以上
303 | */
304 | public static boolean isFlyme4Later() {
305 | return Build.FINGERPRINT.contains("Flyme_OS_4")
306 | || Build.VERSION.INCREMENTAL.contains("Flyme_OS_4")
307 | || Pattern.compile("Flyme OS [4|5]", Pattern.CASE_INSENSITIVE).matcher(Build.DISPLAY).find();
308 | }
309 |
310 | /**
311 | * 判断是否为MIUI6以上
312 | */
313 | public static boolean isMIUI6Later() {
314 | try {
315 | Class> clz = Class.forName("android.os.SystemProperties");
316 | Method mtd = clz.getMethod("get", String.class);
317 | String val = (String) mtd.invoke(null, "ro.miui.ui.version.name");
318 | val = val.replaceAll("[vV]", "");
319 | int versionInt = Integer.parseInt(val);
320 | return versionInt >= 6 && versionInt < 9;
321 | } catch (Exception e) {
322 | return false;
323 | }
324 | }
325 |
326 | public static boolean isDevMIUI() {
327 | try {
328 | Class> clz = Class.forName("android.os.SystemProperties");
329 | Method mtd = clz.getMethod("get", String.class);
330 | String version = (String) mtd.invoke(null, "ro.build.version.incremental");
331 | return version != null && !version.contains("MXDCN");
332 | } catch (Exception e) {
333 | return false;
334 | }
335 | }
336 |
337 | /**
338 | * 增加View的高度以及paddingTop,增加的值为状态栏高度.一般是在沉浸式全屏给ToolBar用的
339 | */
340 | public static void setHeightAndPadding(Context context, View view) {
341 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
342 | ViewGroup.LayoutParams lp = view.getLayoutParams();
343 | lp.height += getStatusBarHeight(context);//增高
344 | view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + getStatusBarHeight(context),
345 | view.getPaddingRight(), view.getPaddingBottom());
346 | }
347 | }
348 |
349 | /**
350 | * 增加View的paddingTop,增加的值为状态栏高度
351 | */
352 | public static void setPadding(Context context, View view) {
353 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
354 | view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + getStatusBarHeight(context),
355 | view.getPaddingRight(), view.getPaddingBottom());
356 | }
357 | }
358 |
359 | /**
360 | * 强制rootView下面的子View的FitsSystemWindows为false
361 | */
362 | public static void forceFitsSystemWindows(Activity activity) {
363 | forceFitsSystemWindows(activity.getWindow());
364 | }
365 |
366 | /**
367 | * 强制rootView下面的子View的FitsSystemWindows为false
368 | */
369 | public static void forceFitsSystemWindows(Window window) {
370 | forceFitsSystemWindows((ViewGroup) window.getDecorView().findViewById(Window.ID_ANDROID_CONTENT));
371 | }
372 |
373 | /**
374 | * 强制rootView下面的子View的FitsSystemWindows为false
375 | */
376 | public static void forceFitsSystemWindows(ViewGroup viewGroup) {
377 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
378 | int count = viewGroup.getChildCount();
379 | for (int i = 0; i < count; i++) {
380 | View view = viewGroup.getChildAt(i);
381 | if (view instanceof ViewGroup) {
382 | forceFitsSystemWindows((ViewGroup) view);
383 | } else {
384 | if (ViewCompat.getFitsSystemWindows(view)) {
385 | ViewCompat.setFitsSystemWindows(view, false);
386 | }
387 | }
388 | }
389 | }
390 | }
391 |
392 | /**
393 | * 是否可以设置浅色的状态栏
394 | */
395 | public static boolean isCanLightStatusBar() {
396 | return SystemBarUtils.isFlyme4Later()
397 | || SystemBarUtils.isMIUI6Later()
398 | || Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
399 | }
400 | }
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/java/com/milo/demo/widget/TranslucentActionBar.java:
--------------------------------------------------------------------------------
1 | package com.milo.demo.widget;
2 |
3 | import android.content.Context;
4 | import android.text.TextUtils;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.LinearLayout;
9 | import android.widget.TextView;
10 |
11 | import com.milo.demo.R;
12 | import com.milo.demo.impl.ActionBarClickListener;
13 |
14 | /**
15 | * 支持渐变的 actionBar
16 | * Created by 晖仔(Milo) on 2016/12/28.
17 | * email:303767416@qq.com
18 | */
19 |
20 | public final class TranslucentActionBar extends LinearLayout {
21 |
22 | public View layRoot;
23 | private View vStatusBar;
24 | private View layLeft;
25 | private View layRight;
26 | public TextView tvTitle;
27 | private TextView tvLeft;
28 | private TextView tvRight;
29 | private View iconLeft;
30 | private View iconRight;
31 |
32 | public TranslucentActionBar(Context context) {
33 | this(context, null);
34 | }
35 |
36 | public TranslucentActionBar(Context context, AttributeSet attrs) {
37 | super(context, attrs);
38 | init();
39 | }
40 |
41 | public TranslucentActionBar(Context context, AttributeSet attrs, int defStyleAttr) {
42 | super(context, attrs, defStyleAttr);
43 | }
44 |
45 | private void init() {
46 | setOrientation(HORIZONTAL);
47 | View contentView = inflate(getContext(), R.layout.actionbar_trans, this);
48 | layRoot = contentView.findViewById(R.id.lay_transroot);
49 | vStatusBar = contentView.findViewById(R.id.v_statusbar);
50 | tvTitle = (TextView) contentView.findViewById(R.id.tv_actionbar_title);
51 | tvLeft = (TextView) contentView.findViewById(R.id.tv_actionbar_left);
52 | tvRight = (TextView) contentView.findViewById(R.id.tv_actionbar_right);
53 | iconLeft = contentView.findViewById(R.id.iv_actionbar_left);
54 | iconRight = contentView.findViewById(R.id.v_actionbar_right);
55 | }
56 |
57 | /**
58 | * 设置状态栏高度
59 | *
60 | * @param statusBarHeight
61 | */
62 | public void setStatusBarHeight(int statusBarHeight) {
63 | ViewGroup.LayoutParams params = vStatusBar.getLayoutParams();
64 | params.height = statusBarHeight;
65 | vStatusBar.setLayoutParams(params);
66 | }
67 |
68 | /**
69 | * 设置是否需要渐变
70 | */
71 | public void setNeedTranslucent() {
72 | setNeedTranslucent(true, false);
73 | }
74 |
75 | /**
76 | * 设置是否需要渐变,并且隐藏标题
77 | *
78 | * @param translucent
79 | */
80 | public void setNeedTranslucent(boolean translucent, boolean titleInitVisibile) {
81 | if (translucent) {
82 | layRoot.setBackgroundDrawable(null);
83 | }
84 | if (!titleInitVisibile) {
85 | tvTitle.setVisibility(View.GONE);
86 | }
87 | }
88 |
89 | /**
90 | * 设置标题
91 | *
92 | * @param strTitle
93 | */
94 | public void setTitle(String strTitle) {
95 | if (!TextUtils.isEmpty(strTitle)) {
96 | tvTitle.setText(strTitle);
97 | } else {
98 | tvTitle.setVisibility(View.GONE);
99 | }
100 | }
101 |
102 | /**
103 | * 设置数据
104 | *
105 | * @param strTitle
106 | * @param resIdLeft
107 | * @param strLeft
108 | * @param resIdRight
109 | * @param strRight
110 | * @param listener
111 | */
112 | public void setData(String strTitle, int resIdLeft, String strLeft, int resIdRight, String strRight, final ActionBarClickListener listener) {
113 | if (!TextUtils.isEmpty(strTitle)) {
114 | tvTitle.setText(strTitle);
115 | } else {
116 | tvTitle.setVisibility(View.GONE);
117 | }
118 | if (!TextUtils.isEmpty(strLeft)) {
119 | tvLeft.setText(strLeft);
120 | tvLeft.setVisibility(View.VISIBLE);
121 | } else {
122 | tvLeft.setVisibility(View.GONE);
123 | }
124 | if (!TextUtils.isEmpty(strRight)) {
125 | tvRight.setText(strRight);
126 | tvRight.setVisibility(View.VISIBLE);
127 | } else {
128 | tvRight.setVisibility(View.GONE);
129 | }
130 |
131 | if (resIdLeft == 0) {
132 | iconLeft.setVisibility(View.GONE);
133 | } else {
134 | iconLeft.setBackgroundResource(resIdLeft);
135 | iconLeft.setVisibility(View.VISIBLE);
136 | }
137 |
138 | if (resIdRight == 0) {
139 | iconRight.setVisibility(View.GONE);
140 | } else {
141 | iconRight.setBackgroundResource(resIdRight);
142 | iconRight.setVisibility(View.VISIBLE);
143 | }
144 |
145 | if (listener != null) {
146 | layLeft = findViewById(R.id.lay_actionbar_left);
147 | layRight = findViewById(R.id.lay_actionbar_right);
148 | layLeft.setOnClickListener(new View.OnClickListener() {
149 | @Override
150 | public void onClick(View v) {
151 | listener.onLeftClick();
152 | }
153 | });
154 | layRight.setOnClickListener(new View.OnClickListener() {
155 | @Override
156 | public void onClick(View v) {
157 | listener.onRightClick();
158 | }
159 | });
160 | }
161 | }
162 |
163 | }
164 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/layout/actionbar_trans.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
18 |
19 |
24 |
25 |
33 |
34 |
45 |
46 |
47 |
53 |
54 |
61 |
62 |
70 |
71 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/layout/activity_actionbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
16 |
17 |
21 |
22 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/layout/activity_demo_first.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
15 |
16 |
22 |
23 |
28 |
29 |
32 |
33 |
38 |
39 |
46 |
47 |
48 |
55 |
56 |
63 |
64 |
71 |
72 |
73 |
74 |
75 |
82 |
83 |
90 |
91 |
96 |
97 |
101 |
102 |
103 |
110 |
111 |
117 |
118 |
123 |
124 |
125 |
132 |
133 |
138 |
139 |
143 |
144 |
145 |
146 |
151 |
152 |
156 |
157 |
163 |
164 |
170 |
171 |
178 |
179 |
191 |
192 |
198 |
199 |
200 |
203 |
204 |
210 |
211 |
217 |
218 |
226 |
227 |
233 |
234 |
235 |
239 |
240 |
246 |
247 |
253 |
254 |
262 |
263 |
269 |
270 |
271 |
274 |
275 |
281 |
282 |
288 |
289 |
297 |
298 |
304 |
305 |
306 |
310 |
311 |
317 |
318 |
324 |
325 |
333 |
334 |
340 |
341 |
342 |
345 |
346 |
352 |
353 |
359 |
360 |
368 |
369 |
375 |
376 |
377 |
381 |
382 |
387 |
388 |
394 |
395 |
403 |
404 |
410 |
411 |
412 |
415 |
416 |
421 |
422 |
428 |
429 |
437 |
438 |
444 |
445 |
446 |
450 |
451 |
457 |
458 |
464 |
465 |
473 |
474 |
480 |
481 |
482 |
486 |
487 |
488 |
489 |
490 |
495 |
496 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/layout/activity_demo_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
17 |
18 |
22 |
23 |
26 |
27 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/layout/view_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
21 |
22 |
23 |
30 |
31 |
38 |
39 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/layout/view_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
21 |
22 |
27 |
28 |
32 |
33 |
34 |
41 |
42 |
48 |
49 |
54 |
55 |
56 |
63 |
64 |
69 |
70 |
74 |
75 |
76 |
77 |
82 |
83 |
87 |
88 |
94 |
95 |
101 |
102 |
109 |
110 |
122 |
123 |
129 |
130 |
131 |
134 |
135 |
141 |
142 |
148 |
149 |
157 |
158 |
164 |
165 |
166 |
170 |
171 |
177 |
178 |
184 |
185 |
193 |
194 |
200 |
201 |
202 |
205 |
206 |
212 |
213 |
219 |
220 |
228 |
229 |
235 |
236 |
237 |
241 |
242 |
248 |
249 |
255 |
256 |
264 |
265 |
271 |
272 |
273 |
276 |
277 |
283 |
284 |
290 |
291 |
299 |
300 |
306 |
307 |
308 |
312 |
313 |
319 |
320 |
326 |
327 |
335 |
336 |
342 |
343 |
344 |
348 |
349 |
350 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/bg_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/bg_avatar.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/bg_banner_my.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/bg_banner_my.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/dft_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/dft_avatar.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_address.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_address.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_agent_my.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_agent_my.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_consume_history.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_consume_history.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_invite_my.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_invite_my.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_left_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_left_light.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_luck_my.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_luck_my.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_right_gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_right_gray.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_set_my.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_set_my.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_shopcar_my.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_shopcar_my.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_sign.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_sign.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_teacher_my.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_teacher_my.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_wallet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxhdpi/ic_wallet.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/values-v19/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #3F51B5
5 | #303F9F
6 | #FF4081
7 |
8 | #fefefe
9 | #3c3c3c
10 | #00000000
11 | #f0eff4
12 | #888888
13 | #f0f0f0
14 | #c9c9c9
15 |
16 | #f2a732
17 |
18 |
19 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 350dp
6 | 100dp
7 |
8 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 滑动伸缩Demo
3 | 作者:Milo
4 | 303767416@qq.com
5 |
6 | 购物车
7 | 购买记录
8 | 钱包
9 | 签到
10 | (今日已签到)
11 | 收货地址
12 | 我的商户
13 | 我要拜师
14 | 开始抽奖
15 | 邀请奖励
16 | 设置
17 |
18 |
--------------------------------------------------------------------------------
/TranslucentScrollView/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
19 |
20 |
26 |
27 |
32 |
33 |
38 |
39 |
44 |
45 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/TranslucentScrollView/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | apply from: rootProject.file('config.gradle')
3 |
4 | buildscript {
5 | repositories {
6 | jcenter()
7 | google()
8 | mavenCentral()
9 | maven {
10 | url 'https://maven.google.com/'
11 | name 'Google'
12 | }
13 | }
14 | dependencies {
15 | classpath 'com.android.tools.build:gradle:3.4.2'
16 |
17 | // NOTE: Do not place your application dependencies here; they belong
18 | // in the individual module build.gradle files
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | jcenter()
25 | google()
26 | }
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/TranslucentScrollView/config.gradle:
--------------------------------------------------------------------------------
1 | ext{
2 | compileSdkVersion = 29
3 | buildToolsVersion = "29.0.2"
4 | minSdkVersion = 17
5 | targetSdkVersion = 29
6 | }
--------------------------------------------------------------------------------
/TranslucentScrollView/gif/device-2016-12-26-192438.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/gif/device-2016-12-26-192438.gif
--------------------------------------------------------------------------------
/TranslucentScrollView/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 |
--------------------------------------------------------------------------------
/TranslucentScrollView/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yanjunhui2014/TranslucentScrollView/f41d284186d6740c01314a4cc044cb0019f4bccf/TranslucentScrollView/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/TranslucentScrollView/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-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/TranslucentScrollView/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 |
--------------------------------------------------------------------------------
/TranslucentScrollView/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 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | def ext = rootProject.ext
5 | compileSdkVersion ext.compileSdkVersion
6 | buildToolsVersion ext.buildToolsVersion
7 |
8 | defaultConfig {
9 | minSdkVersion ext.minSdkVersion
10 | targetSdkVersion ext.targetSdkVersion
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | resourcePrefix "milo_"
26 | }
27 |
28 | dependencies {
29 | implementation fileTree(dir: 'libs', include: ['*.jar'])
30 | }
31 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/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 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/src/main/java/com/milo/lib/PullZoomView.java:
--------------------------------------------------------------------------------
1 | package com.milo.lib;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.LinearLayout;
9 |
10 | import com.milo.lib.impl.IZoomControl;
11 | import com.milo.lib.utils.SizeUtils;
12 |
13 | /**
14 | * 标题:伸缩视图
15 | * 功能:
16 | * 备注:简化封装
17 | *
18 | * Created by Milo 2020/3/3
19 | * E-Mail : 303767416@qq.com
20 | */
21 | public class PullZoomView extends LinearLayout implements IZoomControl {
22 | static final String TAG = PullZoomView.class.getSimpleName();
23 |
24 | public TranslucentScrollView mLayoutTransSV;
25 | public ViewGroup mLayoutContent;
26 |
27 | private View mHeaderView;
28 |
29 | public PullZoomView(Context context) {
30 | super(context);
31 | }
32 |
33 | public PullZoomView(Context context, AttributeSet attrs) {
34 | super(context, attrs);
35 | init(context);
36 | }
37 |
38 | public PullZoomView(Context context, AttributeSet attrs, int defStyleAttr) {
39 | super(context, attrs, defStyleAttr);
40 | init(context);
41 | }
42 |
43 | @Override
44 | public void setHeaderView(int layoutId) {
45 | if (mLayoutContent == null) {
46 | throw new NullPointerException("mLayoutContent为空");
47 | }
48 |
49 | View headerView = LayoutInflater.from(getContext()).inflate(layoutId, mLayoutContent, false);
50 | if (mHeaderView == null) {
51 | mLayoutContent.addView(headerView, 0);
52 | } else {
53 | mLayoutContent.removeViewAt(0);
54 | mLayoutContent.addView(headerView, 0);
55 | }
56 |
57 | mHeaderView = headerView;
58 | mLayoutTransSV.setPullZoomView(headerView);
59 | }
60 |
61 | @Override
62 | public void setHeaderView(View headerView, int viewHeight) {
63 | if (mLayoutContent == null) {
64 | throw new NullPointerException("mLayoutContent为空");
65 | } else if (headerView == null) {
66 | throw new NullPointerException("headerView为空");
67 | } else if (viewHeight <= 0) {
68 | throw new IllegalArgumentException("viewHeight不可以小于0");
69 | }
70 |
71 | if (mHeaderView == null) {
72 | mLayoutContent.addView(headerView, 0);
73 | } else {
74 | mLayoutContent.removeViewAt(0);
75 | mLayoutContent.addView(headerView, 0);
76 | }
77 |
78 | LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) headerView.getLayoutParams();
79 | params.height = SizeUtils.dip2px(getContext(), viewHeight);
80 | headerView.setLayoutParams(params);
81 |
82 | mHeaderView = headerView;
83 | mLayoutTransSV.setPullZoomView(headerView);
84 | }
85 |
86 | @Override
87 | public void addNormalView(int... layoutIds) {
88 | if (mLayoutContent == null) {
89 | throw new NullPointerException("mLayoutContent为空");
90 | } else if (layoutIds == null) {
91 | throw new NullPointerException("layoutIds为空");
92 | }
93 |
94 | for (int layoutId : layoutIds) {
95 | View normalView = LayoutInflater.from(getContext()).inflate(layoutId, mLayoutContent, false);
96 | mLayoutContent.addView(normalView);
97 | }
98 | }
99 |
100 | @Override
101 | public void setDamping(float damping, int dampDistance) {
102 | mLayoutTransSV.setDamping(damping, dampDistance);
103 | }
104 |
105 | @Override
106 | public void attachTransView(View transView, int transColor, int transStartY, int transEndY) {
107 | mLayoutTransSV.setTransView(transView, transColor, transStartY, transEndY);
108 | }
109 |
110 | @Override
111 | public void setTranslucentChangedListener(TranslucentScrollView.TranslucentChangedListener translucentChangedListener) {
112 | mLayoutTransSV.setTranslucentChangedListener(translucentChangedListener);
113 | }
114 |
115 | private void init(Context context) {
116 | addView(LayoutInflater.from(context).inflate(R.layout.milo_zoomview, this, false));
117 | initView();
118 | }
119 |
120 | private void initView() {
121 | mLayoutTransSV = findViewById(R.id.mLayoutTransSV);
122 | mLayoutContent = findViewById(R.id.mLayoutContent);
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/src/main/java/com/milo/lib/TranslucentScrollView.java:
--------------------------------------------------------------------------------
1 | package com.milo.lib;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.animation.ValueAnimator;
5 | import android.content.Context;
6 | import android.graphics.Color;
7 | import android.util.AttributeSet;
8 | import android.util.Log;
9 | import android.view.MotionEvent;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.view.WindowManager;
13 | import android.widget.ScrollView;
14 |
15 | import com.milo.lib.utils.SizeUtils;
16 |
17 | /**
18 | * Created by 晖仔(Milo) on 2017/2/13.
19 | * email:303767416@qq.com
20 | */
21 |
22 | public class TranslucentScrollView extends ScrollView {
23 | static final String TAG = TranslucentScrollView.class.getSimpleName();
24 |
25 | //伸缩视图
26 | private View zoomView;
27 | //伸缩视图初始高度
28 | private int zoomViewInitHeight = 0;
29 | // 记录首次按下位置
30 | private float mFirstPosition = 0;
31 | // 是否正在放大
32 | private Boolean mScaling = false;
33 |
34 | //渐变的视图
35 | private View transView;
36 | //渐变颜色
37 | private int transColor = Color.WHITE;
38 | //渐变开始位置
39 | private int transStartY = 50;
40 | //渐变结束位置
41 | private int transEndY = 300;
42 |
43 | //渐变开始默认位置,Y轴,50dp
44 | public final int DFT_TRANSSTARTY = 50;
45 | //渐变结束默认位置,Y轴,300dp
46 | public final int DFT_TRANSENDY = 300;
47 | //默认阻力开始生效距离
48 | public final int DFT_DAMPDISTANCE = 50;
49 |
50 | //阻力系数
51 | private float mDamping = 0.0f;
52 | //阻力生效距离
53 | private int mDamplDistance = 0;
54 |
55 | private TranslucentScrollView.TranslucentChangedListener translucentChangedListener;
56 |
57 | public interface TranslucentChangedListener {
58 | /**
59 | * 透明度变化,取值范围0-255
60 | *
61 | * @param transAlpha
62 | */
63 | void onTranslucentChanged(int transAlpha);
64 | }
65 |
66 | public TranslucentScrollView(Context context) {
67 | super(context);
68 | }
69 |
70 | public TranslucentScrollView(Context context, AttributeSet attrs) {
71 | super(context, attrs);
72 | mDamplDistance = SizeUtils.dip2px(context, DFT_DAMPDISTANCE);
73 | }
74 |
75 | public TranslucentScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
76 | super(context, attrs, defStyleAttr);
77 | }
78 |
79 | public void setTranslucentChangedListener(TranslucentScrollView.TranslucentChangedListener translucentChangedListener) {
80 | this.translucentChangedListener = translucentChangedListener;
81 | }
82 |
83 | /**
84 | * 设置伸缩视图
85 | *
86 | * @param zoomView
87 | */
88 | public void setPullZoomView(View zoomView) {
89 | this.zoomView = zoomView;
90 | zoomViewInitHeight = zoomView.getLayoutParams().height;
91 | if (zoomViewInitHeight == LayoutParams.MATCH_PARENT || zoomViewInitHeight == WindowManager.LayoutParams.WRAP_CONTENT) {
92 | zoomView.post(new Runnable() {
93 | @Override
94 | public void run() {
95 | zoomViewInitHeight = TranslucentScrollView.this.zoomView.getHeight();
96 | }
97 | });
98 | }
99 | }
100 |
101 | /**
102 | * 设置渐变视图
103 | *
104 | * @param transView 渐变的视图
105 | */
106 | public void setTransView(View transView) {
107 | setTransView(transView, getResources().getColor(R.color.colorPrimary), SizeUtils.dip2px(getContext(), DFT_TRANSSTARTY), SizeUtils.dip2px(getContext(), DFT_TRANSENDY));
108 | }
109 |
110 | /**
111 | * 设置渐变颜色
112 | *
113 | * @param colorRes 渐变的颜色
114 | */
115 | public void setTransColor(int colorRes) {
116 | this.transColor = colorRes;
117 | }
118 |
119 | /**
120 | * 设置渐变视图
121 | *
122 | * @param transView 渐变的视图
123 | * @param transColor 渐变颜色
124 | * @param transEndY 渐变结束位置
125 | */
126 | public void setTransView(View transView, int transColor, int transStartY, int transEndY) {
127 | this.transView = transView;
128 | this.transColor = transColor;
129 | //初始视图-透明
130 | this.transView.setBackgroundColor(setAlphaComponent(transColor, 0));
131 | if (transStartY == -1) {
132 | this.transStartY = SizeUtils.dip2px(getContext(), DFT_TRANSSTARTY);
133 | } else {
134 | this.transStartY = transStartY;
135 | }
136 |
137 | if (transEndY == -1) {
138 | this.transEndY = SizeUtils.dip2px(getContext(), DFT_TRANSENDY);
139 | } else {
140 | this.transEndY = transEndY;
141 | }
142 |
143 | if (this.transEndY == 0) {
144 | throw new IllegalArgumentException("transEndY 不得等于 0 ");
145 | } else if (this.transStartY == this.transEndY) {
146 | throw new IllegalArgumentException("transStartY 不得等于 transEndY .. ");
147 | } else if (this.transStartY > this.transEndY) {
148 | throw new IllegalArgumentException("transStartY 不得大于 transEndY .. ");
149 | }
150 | }
151 |
152 | public void setDamping(float damping, int dampDistance) {
153 | if (damping < 0.0f || damping > 1.0f) {
154 | throw new IllegalArgumentException("damping 取值需要在 0.0f-1.0f 之间");
155 | }
156 | this.mDamping = damping;
157 | if (dampDistance != -1) {
158 | mDamplDistance = SizeUtils.dip2px(getContext(), dampDistance);
159 | }
160 | }
161 |
162 | /**
163 | * 获取透明度
164 | *
165 | * @return
166 | */
167 | private int getTransAlpha() {
168 | float scrollY = getScrollY();
169 | if (transStartY != 0) {
170 | if (scrollY <= transStartY) {
171 | return 0;
172 | } else if (scrollY >= transEndY) {
173 | return 255;
174 | } else {
175 | return (int) ((scrollY - transStartY) / (transEndY - transStartY) * 255);
176 | }
177 | } else {
178 | if (scrollY >= transEndY) {
179 | return 255;
180 | }
181 | return (int) ((transEndY - scrollY) / transEndY * 255);
182 | }
183 | }
184 |
185 | /**
186 | * 重置ZoomView
187 | */
188 | private void resetZoomView() {
189 | final ViewGroup.LayoutParams lp = zoomView.getLayoutParams();
190 | final float h = zoomView.getLayoutParams().height;// ZoomView当前高度
191 |
192 | // 设置动画
193 | ValueAnimator anim = ObjectAnimator.ofFloat(0.0F, 1.0F).setDuration(200);
194 |
195 | anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
196 | @Override
197 | public void onAnimationUpdate(ValueAnimator animation) {
198 | float cVal = (Float) animation.getAnimatedValue();
199 | lp.height = (int) (h - (h - zoomViewInitHeight) * cVal);
200 | zoomView.setLayoutParams(lp);
201 | }
202 | });
203 | anim.start();
204 | }
205 |
206 | @Override
207 | protected void onScrollChanged(int l, int t, int oldl, int oldt) {
208 | super.onScrollChanged(l, t, oldl, oldt);
209 | int transAlpha = getTransAlpha();
210 |
211 | if (transView != null) {
212 | transView.setBackgroundColor(setAlphaComponent(transColor, transAlpha));
213 | }
214 | if (translucentChangedListener != null) {
215 | translucentChangedListener.onTranslucentChanged(transAlpha);
216 | }
217 | }
218 |
219 | @Override
220 | public boolean onTouchEvent(MotionEvent event) {
221 | if (zoomView != null) {
222 | ViewGroup.LayoutParams params = zoomView.getLayoutParams();
223 | switch (event.getAction()) {
224 | case MotionEvent.ACTION_UP:
225 | //手指离开后恢复图片
226 | mScaling = false;
227 | resetZoomView();
228 | break;
229 | case MotionEvent.ACTION_MOVE:
230 | if (!mScaling) {
231 | if (getScrollY() == 0) {
232 | mFirstPosition = event.getY();
233 | } else {
234 | break;
235 | }
236 | }
237 |
238 | int distance = (int) ((event.getY() - mFirstPosition) * 0.6);
239 | if (distance < 0) {
240 | break;
241 | }
242 | mScaling = true;
243 | if (mDamping == 0.0f) {
244 | params.height = zoomViewInitHeight + distance;
245 | } else {
246 | float appendHeight = (distance <= mDamplDistance ? distance : mDamplDistance + ((distance - mDamplDistance) * mDamping));
247 | params.height = zoomViewInitHeight + (int) appendHeight;
248 | }
249 |
250 | zoomView.setLayoutParams(params);
251 | return true;
252 | }
253 | }
254 |
255 | return super.onTouchEvent(event);
256 | }
257 |
258 | private static int setAlphaComponent(int color, int alpha) {
259 | if (alpha < 0 || alpha > 255) {
260 | throw new IllegalArgumentException("alpha must be between 0 and 255.");
261 | }
262 | return (color & 0x00ffffff) | (alpha << 24);
263 | }
264 |
265 | }
266 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/src/main/java/com/milo/lib/impl/IZoomControl.java:
--------------------------------------------------------------------------------
1 | package com.milo.lib.impl;
2 |
3 | import android.view.View;
4 |
5 | import com.milo.lib.TranslucentScrollView;
6 |
7 | /**
8 | * 标题:
9 | * 功能:
10 | * 备注:
11 | *
12 | * Created by Milo 2020/3/3
13 | * E-Mail : 303767416@qq.com
14 | */
15 | public interface IZoomControl {
16 |
17 | void setHeaderView(int layoutId);
18 |
19 | void setHeaderView(View headerView, int viewHeight);
20 |
21 | void addNormalView(int... layoutId);
22 |
23 | /**
24 | * 设置阻力
25 | *
26 | * @param damping 0.0f-1.0f,值越小,阻力越大,0.0f则不能体现出拉伸效果
27 | * @param dampDistance 阻力生效开始距离,-1代表默认值 {@link TranslucentScrollView#DFT_TRANSSTARTY}}
28 | */
29 | void setDamping(float damping, int dampDistance);
30 |
31 | /**
32 | * 关联渐变视图
33 | *
34 | * @param transView - 需要渐变的视图
35 | * @param transColor - 指定渐变色
36 | * @param transStartY - Y轴移动超过该值,渐变开始。-1代表默认值 {@link TranslucentScrollView#DFT_TRANSSTARTY}
37 | * @param transEndY - Y轴移动达到该值,渐变结束。-1代表默认值 {@link TranslucentScrollView#DFT_TRANSENDY}
38 | */
39 | void attachTransView(View transView, int transColor, int transStartY, int transEndY);
40 |
41 | /**
42 | * 设置渐变变化的监听器
43 | *
44 | * @param translucentChangedListener
45 | */
46 | void setTranslucentChangedListener(TranslucentScrollView.TranslucentChangedListener translucentChangedListener);
47 | }
48 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/src/main/java/com/milo/lib/utils/SizeUtils.java:
--------------------------------------------------------------------------------
1 | package com.milo.lib.utils;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * Created by yanjunhui
7 | * on 2016/9/29.
8 | * email:303767416@qq.com
9 | */
10 | public class SizeUtils {
11 |
12 | public static int dip2px(Context context, float dpValue) {
13 | final float scale = context.getResources().getDisplayMetrics().density;
14 | return (int) (dpValue * scale + 0.5f);
15 | }
16 |
17 | /**
18 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
19 | */
20 | public static int px2dip(Context context, float pxValue) {
21 | final float scale = context.getResources().getDisplayMetrics().density;
22 | return (int) (pxValue / scale + 0.5f);
23 | }
24 |
25 | /**
26 | * 将px值转换为sp值,保证文字大小不变
27 | *
28 | * @param pxValue
29 | * @return
30 | */
31 | public static int px2sp(Context context, float pxValue) {
32 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
33 | return (int) (pxValue / fontScale + 0.5f);
34 | }
35 |
36 | /**
37 | * 将sp值转换为px值,保证文字大小不变
38 | *
39 | * @param spValue
40 | * @return
41 | */
42 | public static int sp2px(Context context, float spValue) {
43 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
44 | return (int) (spValue * fontScale + 0.5f);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/src/main/java/com/milo/lib/utils/StatusBarUtils.java:
--------------------------------------------------------------------------------
1 | package com.milo.lib.utils;
2 |
3 | import android.app.Activity;
4 | import android.os.Build;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.view.WindowManager;
8 | import android.widget.LinearLayout;
9 |
10 | /**
11 | * Created by 晖仔(Milo) on 2017/2/13.
12 | * email:303767416@qq.com
13 | */
14 |
15 | public class StatusBarUtils {
16 |
17 | /**
18 | * 使状态栏透明
19 | *
20 | * 适用于图片作为背景的界面,此时需要图片填充到状态栏
21 | *
22 | * @param activity 需要设置的activity
23 | */
24 | public static void setTranslucent(Activity activity) {
25 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
26 | // 设置状态栏透明
27 | activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
28 | // 设置根布局的参数
29 | ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
30 | rootView.setFitsSystemWindows(true);
31 | rootView.setClipToPadding(true);
32 | }
33 | }
34 |
35 | /**
36 | * 设置状态栏颜色
37 | *
38 | * @param activity 需要设置的activity
39 | * @param color 状态栏颜色值
40 | */
41 | public static void setColor(Activity activity, int color) {
42 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
43 | // 设置状态栏透明
44 | activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
45 | // 生成一个状态栏大小的矩形
46 | View statusView = createStatusView(activity, color);
47 | // 添加 statusView 到布局中
48 | ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
49 | decorView.addView(statusView);
50 | // 设置根布局的参数
51 | ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
52 | rootView.setFitsSystemWindows(true);
53 | rootView.setClipToPadding(true);
54 | }
55 | }
56 |
57 | /**
58 | * 生成一个和状态栏大小相同的矩形条
59 | *
60 | * @param activity 需要设置的activity
61 | * @param color 状态栏颜色值
62 | * @return 状态栏矩形条
63 | */
64 | private static View createStatusView(Activity activity, int color) {
65 | // 获得状态栏高度
66 | int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
67 | int statusBarHeight = activity.getResources().getDimensionPixelSize(resourceId);
68 |
69 | // 绘制一个和状态栏一样高的矩形
70 | View statusView = new View(activity);
71 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
72 | statusBarHeight);
73 | statusView.setLayoutParams(params);
74 | statusView.setBackgroundColor(color);
75 | return statusView;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/src/main/res/layout/milo_zoomview.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
--------------------------------------------------------------------------------
/TranslucentScrollView/mylib/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/TranslucentScrollView/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':mylib'
2 |
--------------------------------------------------------------------------------