Search in sources :

Example 1 with Scroller

use of android.widget.Scroller in project Launcher3 by chislon.

the class SmoothPagedView method init.

/**
     * Initializes various states for this workspace.
     */
@Override
protected void init() {
    super.init();
    mScrollMode = getScrollMode();
    if (mScrollMode == DEFAULT_MODE) {
        mBaseLineFlingVelocity = 2500.0f;
        mFlingVelocityInfluence = 0.4f;
        mScrollInterpolator = new OvershootInterpolator();
        mScroller = new Scroller(getContext(), mScrollInterpolator);
    }
}
Also used : Scroller(android.widget.Scroller)

Example 2 with Scroller

use of android.widget.Scroller in project UltimateAndroid by cymcsg.

the class PullDoorView method setupView.

@SuppressLint("NewApi")
private void setupView() {
    // 这个Interpolator你可以设置别的 我这里选择的是有弹跳效果的Interpolator
    Interpolator polator = new BounceInterpolator();
    mScroller = new Scroller(mContext, polator);
    // 获取屏幕分辨率
    WindowManager wm = (WindowManager) (mContext.getSystemService(Context.WINDOW_SERVICE));
    DisplayMetrics dm = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(dm);
    mScreenHeigh = dm.heightPixels;
    mScreenWidth = dm.widthPixels;
    // 这里你一定要设置成透明背景,不然会影响你看到底层布局
    this.setBackgroundColor(Color.argb(0, 0, 0, 0));
    mImgView = new ImageView(mContext);
    mImgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    // 填充整个屏幕
    mImgView.setScaleType(ImageView.ScaleType.FIT_XY);
    // 默认背景
    mImgView.setImageResource(R.drawable.test);
    addView(mImgView);
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) BounceInterpolator(android.view.animation.BounceInterpolator) Interpolator(android.view.animation.Interpolator) Scroller(android.widget.Scroller) ImageView(android.widget.ImageView) DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager) SuppressLint(android.annotation.SuppressLint)

Example 3 with Scroller

use of android.widget.Scroller in project UltimateAndroid by cymcsg.

the class PullDoorView method setupView.

@SuppressLint("NewApi")
private void setupView() {
    Interpolator polator = new BounceInterpolator();
    mScroller = new Scroller(mContext, polator);
    WindowManager wm = (WindowManager) (mContext.getSystemService(Context.WINDOW_SERVICE));
    DisplayMetrics dm = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(dm);
    mScreenHeigh = dm.heightPixels;
    mScreenWidth = dm.widthPixels;
    this.setBackgroundColor(Color.argb(0, 0, 0, 0));
    mImgView = new ImageView(mContext);
    mImgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    mImgView.setScaleType(ImageView.ScaleType.FIT_XY);
    mImgView.setImageResource(R.drawable.circle_button_ic_action_tick);
    addView(mImgView);
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) BounceInterpolator(android.view.animation.BounceInterpolator) Interpolator(android.view.animation.Interpolator) Scroller(android.widget.Scroller) ImageView(android.widget.ImageView) DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager) SuppressLint(android.annotation.SuppressLint)

Example 4 with Scroller

use of android.widget.Scroller in project GreenDroid by cyrilmottier.

the class PagedView method initPagedView.

private void initPagedView() {
    final Context context = getContext();
    mScroller = new Scroller(context, new DecelerateInterpolator());
    final ViewConfiguration conf = ViewConfiguration.get(context);
    // getScaledPagingTouchSlop() only available in API Level 8
    mPagingTouchSlop = conf.getScaledTouchSlop() * 2;
    mMaximumVelocity = conf.getScaledMaximumFlingVelocity();
    final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    mMinimumVelocity = (int) (metrics.density * MINIMUM_PAGE_CHANGE_VELOCITY + 0.5f);
}
Also used : Context(android.content.Context) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ViewConfiguration(android.view.ViewConfiguration) Scroller(android.widget.Scroller) DisplayMetrics(android.util.DisplayMetrics)

Example 5 with Scroller

use of android.widget.Scroller in project android-app by eoecn.

the class XListView method initWithContext.

private void initWithContext(Context context) {
    mScroller = new Scroller(context, new DecelerateInterpolator());
    // XListView need the scroll event, and it will dispatch the event to
    // user's listener (as a proxy).
    super.setOnScrollListener(this);
    // init header view
    mHeaderView = new XListViewHeader(context);
    mHeaderViewContent = (RelativeLayout) mHeaderView.findViewById(R.id.xlistview_header_content);
    mHeaderTimeView = (TextView) mHeaderView.findViewById(R.id.xlistview_header_time);
    addHeaderView(mHeaderView);
    // init footer view
    mFooterView = new XListViewFooter(context);
    // init header height
    mHeaderView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            mHeaderViewHeight = mHeaderViewContent.getHeight();
            getViewTreeObserver().removeGlobalOnLayoutListener(this);
        }
    });
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) Scroller(android.widget.Scroller)

Aggregations

Scroller (android.widget.Scroller)87 ViewConfiguration (android.view.ViewConfiguration)40 Context (android.content.Context)29 Paint (android.graphics.Paint)14 EdgeEffectCompat (android.support.v4.widget.EdgeEffectCompat)14 GestureDetector (android.view.GestureDetector)13 Rect (android.graphics.Rect)12 Point (android.graphics.Point)8 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)7 DisplayMetrics (android.util.DisplayMetrics)6 View (android.view.View)4 OnGlobalLayoutListener (android.view.ViewTreeObserver.OnGlobalLayoutListener)4 BounceInterpolator (android.view.animation.BounceInterpolator)4 Interpolator (android.view.animation.Interpolator)4 SuppressLint (android.annotation.SuppressLint)3 TypedArray (android.content.res.TypedArray)3 LinearInterpolator (android.view.animation.LinearInterpolator)3 ImageView (android.widget.ImageView)3 OverScroller (android.widget.OverScroller)3 Animator (com.nineoldandroids.animation.Animator)3