本文整理汇总了Java中android.support.v4.widget.ScrollerCompat类的典型用法代码示例。如果您正苦于以下问题:Java ScrollerCompat类的具体用法?Java ScrollerCompat怎么用?Java ScrollerCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScrollerCompat类属于android.support.v4.widget包,在下文中一共展示了ScrollerCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CustomViewDragHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* Apps should use ViewDragHelper.create() to get a new instance.
* This will allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context Context to initialize config-dependent params from
* @param forParent Parent view to monitor
*/
private CustomViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}
示例2: ViewDragHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* Apps should use ViewDragHelper.create() to get a new instance. This will
* allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context Context to initialize config-dependent params from
* @param forParent Parent view to monitor
*/
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}
示例3: KDragViewHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* Apps should use ViewDragHelper.create() to get a new instance.
* This will allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context Context to initialize config-dependent params from
* @param forParent Parent view to monitor
*/
private KDragViewHelper(Context context, ViewGroup forParent, android.support.v4.widget.ViewDragHelper.Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}
示例4: ViewDragHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* Apps should use ViewDragHelper.create() to get a new instance.
* This will allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context Context to initialize config-dependent params from
* @param forParent Parent view to monitor
*/
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}
示例5: ViewDragHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* Apps should use ViewDragHelper.create() to get a new instance. This will
* allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context
* Context to initialize config-dependent params from
* @param forParent
* Parent view to monitor
*/
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}
示例6: ViewDragHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* Apps should use ViewDragHelper.create() to get a new instance.
* This will allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context Context to initialize config-dependent params from
* @param forParent Parent view to monitor
*/
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}
示例7: SlideViewDragHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* Apps should use ViewDragHelper.create() to get a new instance.
* This will allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context Context to initialize config-dependent params from
* @param forParent Parent view to monitor
*/
private SlideViewDragHelper(Context context, ViewGroup forParent, SlideViewDragHelper.Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}
示例8: ViewDragHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
} else if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
} else {
this.mParentView = forParent;
this.mCallback = cb;
ViewConfiguration vc = ViewConfiguration.get(context);
this.mEdgeSize = (int) ((20.0f * context.getResources().getDisplayMetrics().density)
+ 0.5f);
this.mTouchSlop = vc.getScaledTouchSlop();
this.mMaxVelocity = (float) vc.getScaledMaximumFlingVelocity();
this.mMinVelocity = (float) vc.getScaledMinimumFlingVelocity();
this.mScroller = ScrollerCompat.create(context, sInterpolator);
}
}
示例9: fling
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
final boolean fling(CoordinatorLayout coordinatorLayout, V layout, int minOffset, int maxOffset, float velocityY) {
if (this.mFlingRunnable != null) {
layout.removeCallbacks(this.mFlingRunnable);
this.mFlingRunnable = null;
}
if (this.mScroller == null) {
this.mScroller = ScrollerCompat.create(layout.getContext());
}
this.mScroller.fling(0, getTopAndBottomOffset(), 0, Math.round(velocityY), 0, 0, minOffset, maxOffset);
if (this.mScroller.computeScrollOffset()) {
this.mFlingRunnable = new FlingRunnable(coordinatorLayout, layout);
ViewCompat.postOnAnimation(layout, this.mFlingRunnable);
return true;
}
onFlingFinished(coordinatorLayout, layout);
return false;
}
示例10: getLastVelocity
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* 滚动结束后时的速率
*/
public float getLastVelocity() {
Object mViewFlinger = Reflect.getMember(RecyclerView.class, this, "mViewFlinger");
Object mScroller = Reflect.getMember(mViewFlinger, "mScroller");
float currVelocity = 0f;
if (mScroller instanceof OverScroller) {
currVelocity = ((OverScroller) mScroller).getCurrVelocity();
} else if (mScroller instanceof ScrollerCompat) {
currVelocity = ((ScrollerCompat) mScroller).getCurrVelocity();
} else {
throw new IllegalArgumentException("未兼容的mScroller类型:" + mScroller.getClass().getSimpleName());
}
if (Float.isNaN(currVelocity)) {
currVelocity = mLastVelocity;
} else {
mLastVelocity = currVelocity;
}
return currVelocity;
}
示例11: TranslationViewDragHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* Apps should use ViewDragHelper.create() to get a new instance.
* This will allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context Context to initialize config-dependent params from
* @param forParent Parent view to monitor
*/
private TranslationViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}
示例12: ViewDragHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* Apps should use ViewDragHelper.create() to get a new instance. This will
* allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context Context to initialize config-dependent params from
* @param forParent Parent view to monitor
*/
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}
示例13: init
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/** 初始化一些常量 */
private void init() {
//把一个值从dip转换成px
mIndicatorHeight = UIUtils.dip2px(mIndicatorHeight);
mDividerPadding = UIUtils.dip2px(mDividerPadding);
mTabPadding = UIUtils.dip2px(mTabPadding);
mDividerWidth = UIUtils.dip2px(mDividerWidth);
mTabTextSize = UIUtils.dip2px(mTabTextSize);
//创建一个scroller
mScroller = ScrollerCompat.create(mActivity);
//获取一个系统关于View的常量配置类
final ViewConfiguration configuration = ViewConfiguration.get(mActivity);
//获取滑动的最小距离
mTouchSlop = configuration.getScaledTouchSlop();
//获取fling的最小速度
mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
//获取fling的最大速度
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mLeftEdge = new EdgeEffectCompat(mActivity);
mRightEdge = new EdgeEffectCompat(mActivity);
}
示例14: ViewDragHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* Apps should use ViewDragHelper.create() to get a new instance. This will
* allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context Context to initialize config-dependent params from
* @param forParent Parent view to monitor
*/
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}
示例15: ViewDragHelper
import android.support.v4.widget.ScrollerCompat; //导入依赖的package包/类
/**
* Apps should use ViewDragHelper.create() to get a new instance. This will
* allow VDH to use internal compatibility implementations for different
* platform versions.
*
* @param context Context to initialize config-dependent params from
* @param forParent Parent view to monitor
*/
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
}
if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
}
mParentView = forParent;
mCallback = cb;
final ViewConfiguration vc = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);
mTouchSlop = vc.getScaledTouchSlop();
mMaxVelocity = vc.getScaledMaximumFlingVelocity();
mMinVelocity = vc.getScaledMinimumFlingVelocity();
mScroller = ScrollerCompat.create(context, sInterpolator);
}