├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── Screenshot ├── bouncing-jelly-view-recyclerview.gif └── bouncing-jelly-view普通情况.gif ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── aohanyao │ │ └── bouncingjelly │ │ ├── ListActivity.java │ │ ├── MainActivity.java │ │ ├── ScrollActivity.java │ │ └── adapter │ │ └── RecyclerAdapter.java │ └── res │ ├── drawable │ ├── ic_chevron_right_black_24dp.xml │ └── ic_settings_black_24dp.xml │ ├── layout │ ├── activity_list.xml │ ├── activity_main.xml │ ├── activity_main2.xml │ ├── activity_main22.xml │ ├── activity_scroll.xml │ ├── content_list.xml │ ├── content_main.xml │ ├── content_main2.xml │ ├── content_scroll.xml │ ├── layout_list_item.xml │ └── layout_setting_item.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ ├── icon_20_turn_right.png │ └── info.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-v21 │ └── styles.xml │ ├── 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 ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── aohanyao │ │ └── jelly │ │ └── library │ │ ├── BouncingJellyView.java │ │ ├── inf │ │ └── BouncingJellyListener.java │ │ └── util │ │ ├── BouncingInterpolatorType.java │ │ ├── BouncingScreenUtils.java │ │ └── BouncingType.java │ └── res │ └── values │ ├── attr.xml │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 35 | 36 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 84 | 94 | 95 | 96 | 97 | 98 | 99 | 101 | 102 | 103 | 104 | 105 | 1.8 106 | 107 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##BouncingJellyView 2 | 3 | ### 最新版本: [![](https://jitpack.io/v/aohanyao/BouncingJelly.svg)](https://jitpack.io/#aohanyao/BouncingJelly) 4 | 5 | 可以嵌套任何View,滑动到顶部或者底部,会有一个阻尼效果进行缩放整个页面,松开手指回弹。灵感来自于MIUI。 6 | 7 | ### 效果图 8 | #### 1. 普通的页面 9 | ![嵌套普通的View](Screenshot/bouncing-jelly-view%E6%99%AE%E9%80%9A%E6%83%85%E5%86%B5.gif) 10 | #### 2. 嵌套RecyclerView 11 | ![嵌套RecyclerView](Screenshot/bouncing-jelly-view-recyclerview.gif) 12 | ### 使用 13 | 1. 添加Jitpack 14 | 15 | allprojects { 16 | repositories { 17 | ... 18 | maven { url 'https://jitpack.io' } 19 | } 20 | } 21 | 22 | 2. 在gradle中compile 23 | 24 | compile 'com.github.aohanyao:BouncingJelly:1.0.4' 25 | 26 | 3. xml 27 | 28 | 因为BouncingJellyView是继承自ScrollView,所以必须要嵌套一层ViewGroup才能使用。 29 | 30 | 31 | ```xml 32 | 33 | 38 | 39 | <任意ViewGroup> 40 | .........你的内容 41 | 42 | 43 | 44 | 45 | ``` 46 | 47 | 48 | 49 | 50 | ### Version History 51 | ### 2018年3月6日 52 | 修复[issues/1#](https://github.com/aohanyao/BouncingJelly/issues/1#issuecomment-370310890) 53 | 54 | #### 2018年3月5日 55 | 剔除多余的包 56 | 57 | #### 2017年1月11日 58 | 1.0.0 59 | 60 | 初步完成,增加到仓库。 -------------------------------------------------------------------------------- /Screenshot/bouncing-jelly-view-recyclerview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aohanyao/BouncingJelly/e2771db74658938fbffb3618a111a85c8c33915a/Screenshot/bouncing-jelly-view-recyclerview.gif -------------------------------------------------------------------------------- /Screenshot/bouncing-jelly-view普通情况.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aohanyao/BouncingJelly/e2771db74658938fbffb3618a111a85c8c33915a/Screenshot/bouncing-jelly-view普通情况.gif -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | //apply plugin: 'kotlin-android' 3 | android { 4 | compileSdkVersion 24 5 | buildToolsVersion "26.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.aohanyao.bouncingjelly" 9 | minSdkVersion 15 10 | targetSdkVersion 24 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | 22 | } 23 | 24 | dependencies { 25 | compile fileTree(include: ['*.jar'], dir: 'libs') 26 | testCompile 'junit:junit:4.12' 27 | compile 'com.android.support:appcompat-v7:24.2.1' 28 | compile 'com.android.support:design:24.2.1' 29 | compile 'com.android.support:cardview-v7:24.2.1' 30 | compile project(':library') 31 | } 32 | -------------------------------------------------------------------------------- /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 D:\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 24 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/aohanyao/bouncingjelly/ListActivity.java: -------------------------------------------------------------------------------- 1 | package com.aohanyao.bouncingjelly; 2 | 3 | import android.os.Bundle; 4 | import android.os.Handler; 5 | import android.support.v4.widget.SwipeRefreshLayout; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.support.v7.widget.LinearLayoutManager; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.support.v7.widget.Toolbar; 10 | 11 | import com.aohanyao.bouncingjelly.adapter.RecyclerAdapter; 12 | 13 | public class ListActivity extends AppCompatActivity { 14 | 15 | private RecyclerView rl; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_list); 21 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 22 | setSupportActionBar(toolbar); 23 | rl = (RecyclerView) findViewById(R.id.rl); 24 | initRecyclerView(); 25 | } 26 | 27 | private void initRecyclerView() { 28 | RecyclerAdapter mAdapter = new RecyclerAdapter(this); 29 | LinearLayoutManager layoutManager = new LinearLayoutManager(this); 30 | layoutManager.setOrientation(LinearLayoutManager.VERTICAL); 31 | rl.setLayoutManager(layoutManager); 32 | rl.setAdapter(mAdapter); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/aohanyao/bouncingjelly/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.aohanyao.bouncingjelly; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.Toolbar; 7 | import android.view.Menu; 8 | import android.view.MenuItem; 9 | import android.view.View; 10 | 11 | public class MainActivity extends AppCompatActivity { 12 | 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_main); 18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 19 | setSupportActionBar(toolbar); 20 | } 21 | 22 | public void ordinary(View view) { 23 | startActivity(new Intent(this, ScrollActivity.class)); 24 | } 25 | 26 | public void list(View view) { 27 | startActivity(new Intent(this, ListActivity.class)); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/aohanyao/bouncingjelly/ScrollActivity.java: -------------------------------------------------------------------------------- 1 | package com.aohanyao.bouncingjelly; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.Toolbar; 6 | 7 | public class ScrollActivity extends AppCompatActivity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_scroll); 13 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 14 | setSupportActionBar(toolbar); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/aohanyao/bouncingjelly/adapter/RecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.aohanyao.bouncingjelly.adapter; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.aohanyao.bouncingjelly.R; 11 | 12 | import java.util.Random; 13 | 14 | /** 15 | *

作者:江俊超 on 2016/8/31 11:00

16 | *

邮箱:928692385@qq.com

17 | *

18 | */ 19 | public class RecyclerAdapter extends RecyclerView.Adapter { 20 | private Context mContext; 21 | 22 | public RecyclerAdapter(Context mContext) { 23 | this.mContext = mContext; 24 | } 25 | 26 | @Override 27 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 28 | View view = LayoutInflater.from(mContext).inflate(R.layout.layout_list_item, null); 29 | return new ViewHolder(view); 30 | } 31 | 32 | @Override 33 | public void onBindViewHolder(ViewHolder holder, int position) { 34 | holder.setBg(); 35 | } 36 | 37 | @Override 38 | public int getItemCount() { 39 | return 20; 40 | } 41 | 42 | class ViewHolder extends RecyclerView.ViewHolder { 43 | private View v_forget; 44 | 45 | public ViewHolder(View itemView) { 46 | super(itemView); 47 | v_forget= itemView.findViewById(R.id.v_forget); 48 | } 49 | 50 | public void setBg() { 51 | v_forget.setBackgroundColor(Color.parseColor(getRandColorCode())); 52 | } 53 | } 54 | 55 | /** 56 | * 获取十六进制的颜色代码.例如 "#6E36B4" , For HTML , 57 | * 58 | * @return String 59 | */ 60 | public String getRandColorCode() { 61 | String r, g, b; 62 | Random random = new Random(); 63 | r = Integer.toHexString(random.nextInt(256)).toUpperCase(); 64 | g = Integer.toHexString(random.nextInt(256)).toUpperCase(); 65 | b = Integer.toHexString(random.nextInt(256)).toUpperCase(); 66 | 67 | r = r.length() == 1 ? "0" + r : r; 68 | g = g.length() == 1 ? "0" + g : g; 69 | b = b.length() == 1 ? "0" + b : b; 70 | 71 | return "#FF"+r + g + b; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_chevron_right_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_settings_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main2.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main22.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_scroll.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 16 | 17 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 |