當前位置: 首頁>>代碼示例>>Java>>正文


Java OverScroller類代碼示例

本文整理匯總了Java中android.widget.OverScroller的典型用法代碼示例。如果您正苦於以下問題:Java OverScroller類的具體用法?Java OverScroller怎麽用?Java OverScroller使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OverScroller類屬於android.widget包,在下文中一共展示了OverScroller類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: reflectAbsListView

import android.widget.OverScroller; //導入依賴的package包/類
private void reflectAbsListView() {
    try {
        Class<?> absListViewCls = Class.forName("android.widget.AbsListView");
        Field mFlingRunnableField = absListViewCls.getDeclaredField("mFlingRunnable");
        mFlingRunnableField.setAccessible(true);
        Object mFlingRunnable = mFlingRunnableField.get(mListView);


        Class<?> flingRunnableCls = Class.forName("android.widget.AbsListView$FlingRunnable");
        Field mScrollerFeild = flingRunnableCls.getDeclaredField("mScroller");
        mScrollerFeild.setAccessible(true);
        mScrollerReflectd = (OverScroller) mScrollerFeild.get(mFlingRunnable);
    } catch (Exception e) {
        mScrollerReflectd = null;
        Log.d(TAG, "###Exception Stack###", new Throwable(e));
    }
}
 
開發者ID:lorienzhang,項目名稱:WLLayout,代碼行數:18,代碼來源:WLLayout.java

示例2: ResolverDrawerLayout

import android.widget.OverScroller; //導入依賴的package包/類
public ResolverDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ResolverDrawerLayout,
            defStyleAttr, 0);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.ResolverDrawerLayout_android_maxWidth, -1);
    mMaxCollapsedHeight = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeight, 0);
    mMaxCollapsedHeightSmall = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeightSmall,
            mMaxCollapsedHeight);
    a.recycle();

    mScrollIndicatorDrawable = context.getDrawable(R.drawable.scroll_indicator_material);

    mScroller = new OverScroller(context, AnimationUtils.loadInterpolator(context,
            android.R.interpolator.decelerate_quint));
    mVelocityTracker = VelocityTracker.obtain();

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();

    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
 
開發者ID:RikkaW,項目名稱:Bridge,代碼行數:26,代碼來源:ResolverDrawerLayout.java

示例3: computeScroll

import android.widget.OverScroller; //導入依賴的package包/類
@Override
public void computeScroll() {
    boolean scrollerWorkNow = SCROLL_STATE_SETTLING == mScrollState;
    OverScroller scroller = scrollerWorkNow ? getScroller() : null;
    if (scroller != null && scroller.computeScrollOffset()) {
        int oldX = getScrollX();
        int oldY = getScrollY();
        int x = scroller.getCurrX();
        int y = scroller.getCurrY();
        if (oldX != x || oldY != y) {
            scrollTo(x, y);
        }
        ViewCompat.postInvalidateOnAnimation(this);
    } else {
        if (scrollerWorkNow) {
            markAsWillIdle();
        }
    }
}
 
開發者ID:rexyren,項目名稱:PageScrollView,代碼行數:20,代碼來源:PageScrollView.java

示例4: SpringView

import android.widget.OverScroller; //導入依賴的package包/類
public SpringView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
    inflater = LayoutInflater.from(context);

    mScroller = new OverScroller(context);

    //獲取自定義屬性
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SpringView);
    if (ta.hasValue(R.styleable.SpringView_type)){
        int type_int = ta.getInt(R.styleable.SpringView_type, 0);
        type = Type.values()[type_int];
    }
    if (ta.hasValue(R.styleable.SpringView_give)){
        int give_int = ta.getInt(R.styleable.SpringView_give, 0);
        give = Give.values()[give_int];
    }
    if (ta.hasValue(R.styleable.SpringView_header)){
        headerResoureId = ta.getResourceId(R.styleable.SpringView_header, 0);
    }
    if (ta.hasValue(R.styleable.SpringView_footer)){
        footerResoureId = ta.getResourceId(R.styleable.SpringView_footer, 0);
    }
    ta.recycle();
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:26,代碼來源:SpringView.java

示例5: init

import android.widget.OverScroller; //導入依賴的package包/類
private void init() {
        configuration = ViewConfiguration.get(getContext());
        mScroller = new Scroller(getContext(), new OvershootInterpolator(0.75f));
        flingRunnable = new FlingRunnable();
        overScrollRunnable = new OverScrollRunnable();
        flingScroller = new OverScroller(getContext());
        detector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
            @Override
            public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                if (isOverScrollTop || isOverScrollBottom || isOverScrollLeft || isOverScrollRight) {
                    return false;
                }
//
                flingRunnable.start(velocityX, velocityY);
                return false;
            }
        });
    }
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:19,代碼來源:OverScrollLayout.java

示例6: getLastVelocity

import android.widget.OverScroller; //導入依賴的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;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:23,代碼來源:RRecyclerView.java

示例7: SwipeMenuLayout

import android.widget.OverScroller; //導入依賴的package包/類
public SwipeMenuLayout(Context context, AttributeSet attrs,
                       int defStyle) {
    super(context, attrs, defStyle);

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwipeMenuLayout);
    mLeftViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_leftViewId, mLeftViewId);
    mContentViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_contentViewId, mContentViewId);
    mRightViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_rightViewId, mRightViewId);
    typedArray.recycle();

    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mScaledTouchSlop = configuration.getScaledTouchSlop();
    mScaledMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mScaledMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity();

    mScroller = new OverScroller(getContext());
}
 
開發者ID:leobert-lan,項目名稱:UiLib,代碼行數:18,代碼來源:SwipeMenuLayout.java

示例8: initLayout

import android.widget.OverScroller; //導入依賴的package包/類
private void initLayout() {
    mOverScroller = new OverScroller(getContext());
    mGestureDetectorCompat = new GestureDetectorCompat(getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, final float velocityY) {
                    if (Math.abs(velocityX) > Math.abs(velocityY)) {
                        return false;
                    }

                    if (isFloat() /*&& velocityY < 0*/) {
                        return false;
                    }
                    fling(velocityY);
                    return true;
                }
            });
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:20,代碼來源:StickLayout2.java

示例9: init

import android.widget.OverScroller; //導入依賴的package包/類
private void init(Context context) {
    setOrientation(VERTICAL);

    mOverScroller = new OverScroller(context);
    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:BGAStickyNavLayout.java

示例10: PullToRefreshView

import android.widget.OverScroller; //導入依賴的package包/類
public PullToRefreshView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mInflater = LayoutInflater.from(context);
    mScroller = new OverScroller(context);

    //獲取自定義屬性
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.PullToRefresh);
    if (ta.hasValue(R.styleable.PullToRefresh_header_indicator)) {
        mHeaderIndicatorClassName = ta.getString(R.styleable.PullToRefresh_header_indicator);
    }
    if (ta.hasValue(R.styleable.PullToRefresh_footer_indicator)) {
        mFooterIndicatorClassName = ta.getString(R.styleable.PullToRefresh_footer_indicator);
    }
    ta.recycle();
}
 
開發者ID:guzhigang001,項目名稱:Bailan,代碼行數:16,代碼來源:PullToRefreshView.java

示例11: CompatScroller

import android.widget.OverScroller; //導入依賴的package包/類
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
開發者ID:sherlockchou86,項目名稱:yphoto,代碼行數:11,代碼來源:TouchImageView.java

示例12: SwipeMenuLayout

import android.widget.OverScroller; //導入依賴的package包/類
public SwipeMenuLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwipeMenuLayout);
        mLeftViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_leftViewId, mLeftViewId);
        mContentViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_contentViewId, mContentViewId);
        mRightViewId = typedArray.getResourceId(R.styleable.SwipeMenuLayout_rightViewId, mRightViewId);
        typedArray.recycle();

        ViewConfiguration mViewConfig = ViewConfiguration.get(getContext());
        mScaledTouchSlop = mViewConfig.getScaledTouchSlop();
        mScroller = new OverScroller(getContext());
        mScaledMinimumFlingVelocity = mViewConfig.getScaledMinimumFlingVelocity();
        mScaledMaximumFlingVelocity = mViewConfig.getScaledMaximumFlingVelocity();
}
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:16,代碼來源:SwipeMenuLayout.java

示例13: CompatScroller

import android.widget.OverScroller; //導入依賴的package包/類
public CompatScroller(Context context) {
  if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
    isPreGingerbread = true;
    scroller = new Scroller(context);
  } else {
    isPreGingerbread = false;
    overScroller = new OverScroller(context);
  }
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:10,代碼來源:TouchImageView.java

示例14: CompatScroller

import android.widget.OverScroller; //導入依賴的package包/類
public CompatScroller(Context context) {
	if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
		isPreGingerbread = true;
		scroller = new Scroller(context);
		
	} else {
		isPreGingerbread = false;
		overScroller = new OverScroller(context);
	}
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:11,代碼來源:TouchImageView.java

示例15: XRefreshLayout

import android.widget.OverScroller; //導入依賴的package包/類
public XRefreshLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    MIN_LOADING_LAYOUG_HEIGHT = DensityUtil.dip2px(context, MIN_LOADING_LAYOUG_HEIGHT);
    OVERSCROLL_RANGE = DensityUtil.dip2px(context, OVERSCROLL_RANGE);

    scroller = new OverScroller(getContext());
    loadingLayout = new DefaultLoadingLayout();
}
 
開發者ID:BeautifulMy,項目名稱:xRecycleView,代碼行數:10,代碼來源:XRefreshLayout.java


注:本文中的android.widget.OverScroller類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。