• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    Java
  • Created about 8 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Add the over-scroll feature to any scrollable view: RecyclerView, ScrollView, WebView, ListView, GridView, etc. Support both fling and drag over-scroll,and easy to customize the over-scroll style. 为任意可滑动的View定制越界效果(over-scroll),同时支持滑动惯性越界与拖动越界,方便地定制与扩展不同的越界风格。实现iOS弹性越界效果、微信“网页由xxx.com提供”的WebView效果、MIUI8的越界拉伸放大效果。

OverScroll-Everywhere

Add the over-scroll feature to any scrollable view: RecyclerView, ScrollView, WebView, ListView, GridView, etc. Support both fling and drag over-scroll,and easy to customize the over-scroll style.

为任意可滑动的View定制越界效果(over-scroll),同时支持滑动惯性越界与拖动越界,方便地定制与扩展不同的越界风格。实现iOS弹性越界效果、微信“网页由xxx.com提供”的WebView效果、MIUI8的越界拉伸放大效果。 注:安卓本身使用EdgeEffect绘制越界效果(边缘发亮),安卓4.x为固定的holo_blue色,5.0+为半透明colorPrimary色。

OverScroll-Everywhere

Sample

OverScroll-EverywhereSample.apk

GIF

Usage

  • Use OverScrollRecyclerView OverScrollScrollView OverScrollWebView OverScrollListView OverScrollGridView to replace the original one.

  • Enable or disable fling/drag over-scroll

     	OverScrollRecyclerView yourOverScrollRecyclerView = ...;
     	boolean dragOverScroll = true | false;
     	boolean flingOverScroll = true | false;
     	yourOverScrollRecyclerView.getOverScrollDelegate().setOverScrollType(dragOverScroll, flingOverScroll);

Style

  • Perset style

     	//Show your logo at top
     	Drawable yourLogo = ...;
     	yourOverScrollRecyclerView.getOverScrollDelegate().setOverScrollStyle(new LogoOverScrollStyle(yourLogo));
     	
     	//Like MIUI8
     	yourOverScrollRecyclerView.getOverScrollDelegate().setOverScrollStyle(new Miui8OverScrollStyle());
     	
     	//Show the host of webpage at top 
     	yourOverScrollWebView.getOverScrollDelegate().setOverScrollStyle(new WebHostOverScrollStyle() {
     		@Override
     		public String formatUrlHost(String url) {
     			try {
     				return "Provided by " + new URL(url).getHost();
     			} catch (Exception e) {
     			}
     			return "";
     		}
     	});
  • Customize your style

     	OverScrollStyle yourOverScrollStyle = new OverScrollStyle() {
     		/**
     		 * Transform canvas before draw content, 
     		 * for example, do canvas.translate
     		 */
     		public void transformOverScrollCanvas(float offsetY, Canvas canvas, View view) {
     			final int translateY = Math.round(offsetY * DEFAULT_DRAW_TRANSLATE_RATE);
     			canvas.translate(0, translateY);
     		}
    
     		/**
     		 * Draw overscroll effect(e.g. logo) at top, the direction of offsetY is
     		 * same as TouchEvent
     		 */
     		public void drawOverScrollTop(float offsetY, Canvas canvas, View view) {
     			//draw someting
     		};
    
     		/**
     		 * Draw overscroll effect(e.g. logo) at bottom, the direction of offsetY
     		 * is same as TouchEvent
     		 */
     		public void drawOverScrollBottom(float offsetY, Canvas canvas, View view) {
     			//draw someting
     		};
     	};
     	yourOverScrollRecyclerView.getOverScrollDelegate().setOverScrollStyle(yourOverScrollStyle);

Use with FastScroll-Everywhere

  • Like this
     	public class FastAndOverScrollScrollView extends ScrollView implements FastScrollable, OverScrollable {
     		
     		private FastScrollDelegate mFastScrollDelegate;
     		private OverScrollDelegate mOverScrollDelegate;
     		
     		public FastAndOverScrollScrollView(Context context, AttributeSet attrs) {
     			super(context, attrs);
     			createDelegates(context);
     		}
     		
     		// ===========================================================
     		// createDelegates
     		// ===========================================================
     		private void createDelegates(Context context) {
     			mFastScrollDelegate = new FastScrollDelegate.Builder(this).build();
     			mOverScrollDelegate = new OverScrollDelegate(this);
     		}
    
     		// ===========================================================
     		// Modify these 3 methods, others are same as source code.
     		// ===========================================================
     		@Override
     		public boolean onInterceptTouchEvent(MotionEvent ev) {
     			if (mFastScrollDelegate.onInterceptTouchEvent(ev)) {
     				return true;
     			}
     			if (mOverScrollDelegate.onInterceptTouchEvent(ev)) {
     				return true;
     			}
     			return super.onInterceptTouchEvent(ev);
     		}
    
     		@Override
     		public boolean onTouchEvent(MotionEvent event) {
     			if (mFastScrollDelegate.onTouchEvent(event)) {
     				return true;
     			}
     			if (mOverScrollDelegate.onTouchEvent(event)) {
     				return true;
     			}
     			return super.onTouchEvent(event);
     		}
    
     		@Override
     		public boolean superAwakenScrollBars() {
     			// Just call mFastScrollDelegate.awakenScrollBars()
     			// Do not call super
     			return awakenScrollBars();
     		}
     		
     		// ===========================================================
     		// Copy other methods from source code.
     		// ===========================================================
     	
     	}
     

Extension (OverScroll-Everywhere!)

  • If you want to add the over-scroll feature to your CustomScrollableView, just copy the source code of OverScrollScrollView(or any OverScrollXxxxView) and change the super-class to your CustomScrollableView.
  • Then, all done. All things are handled by OverScrollDelegate

Attention

  • In RecyclerView, we override the package-method absorbGlows to get the velocity of fling overscroll.
  • In other views, we override the protected-method overScrollBy to compute the velocity of fling overscroll.

Developed By

Mixiaoxiao(谜小小) - [email protected] or [email protected]

License

Copyright 2016 Mixiaoxiao

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

Arduino-HomeKit-ESP8266

Native Apple HomeKit accessory implementation for the ESP8266 Arduino core.
C
1,515
star
2

Weather

A beautiful weather app: DynamicBackground (clear, rainy, foggy, etc), AqiView, DailyForecastView, HourlyForecastView and more. 一款精致的天气APP,动态天气背景(10*2种天气效果,每种区分白天和夜间)、一周天气曲线图、24H曲线图、空气质量/风速/日出日落图等。
Java
459
star
3

ESP8266-IR-HOMEKIT

原生HomeKit红外空调遥控
355
star
4

Arduino-HomeKit-ESP32

[Deprecated] Native Apple HomeKit accessory implementation for the ESP32 Arduino core.
C
226
star
5

SmoothCompoundButton

Android CompoundButtons (Switch, CheckBox, RadioButton) in Material Design, works on Android 4.0+(SDK 14). SmoothCompoundButton 是全套Material风格的Switch、CheckBox和RadioButton组件,纯Java代码(非贴图)像素级复刻了Material动画与阴影效果,支持Android 4.0+。基本实现了在不同Android版本上与Material风格一致的效果,体验优于官方AppCompat,可能是目前最好的Material风格CompoundButton组件之一。
Java
144
star
6

FastScroll-Everywhere

Add the fast-scroll feature to any scrollable view: RecyclerView, ScrollView, WebView, ListView, GridView, etc. 为任意可滑动的View添加快速滑动,是的,任意。
Java
85
star
7

9GAG

9GAG-Android (unofficial), Android Design.
Java
71
star
8

Arduino-HomeKit-ESP

Arduino library version of espressif's official esp-homekit-sdk.
C
56
star
9

SplitLayout

Android SplitLayout, which splits the available space between two child views by dragging the center handle. 安卓分栏布局,包含2个子View,支持横向或纵向分栏,可通过拖动中间的handle来动态分割两个子View所占空间。
Java
36
star
10

NotificationTextColorCompat

Fetch the default system notification text color (ContentTitleColor and ContentTextColor) for your custom RemoteViews. 获取系统默认的通知文字颜色(标题和内容文字颜色),适配自定义通知的RemoteViews中的文字。已测试兼容各种国产ROM。
Java
21
star
11

StatusBarColorCompat

Change the StatusBarColor dynamically, works on Android 4.4+. 简单优雅地动态改变状态栏颜色,支持安卓4.4+。
Java
18
star
12

ESP32-HOMEKIT-GATEWAY

ESP32-HOMEKIT-GATEWAY
9
star
13

mixiaoxiao.github.io

CSS
4
star
14

DataStateContainer

DataStateContainer是一个专为处理数据刷新/加载逻辑业务(如微博信息流)而生的ViewGroup。
Java
3
star
15

ActionMenu

A lite library to show an action-menubar like the menus(copy, select all, paste) for UILabel in iOS.
Java
3
star
16

PathScroller

A Scroller that can compute the "value - time" by a Path. 一个依据Path来映射“数值-时间”关系的Scroller,可轻松实现速率变化复杂的Scroll效果。
Java
2
star
17

ZoneAssistiveTouch_TranslationProject

ZoneAssistiveTouch TranslationProject
2
star