List of usage examples for android.widget OverScroller OverScroller
public OverScroller(Context context)
From source file:com.google.android.apps.muzei.util.PanScaleProxyView.java
public PanScaleProxyView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setWillNotDraw(true);/*from w w w. j a v a 2 s. c o m*/ // Sets up interactions mScaleGestureDetector = new ScaleGestureDetector(context, mScaleGestureListener); ScaleGestureDetectorCompat.setQuickScaleEnabled(mScaleGestureDetector, true); mGestureDetector = new GestureDetectorCompat(context, mGestureListener); mScroller = new OverScroller(context); mZoomer = new Zoomer(context); }
From source file:com.android.photos.views.GalleryThumbnailView.java
public GalleryThumbnailView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMaximumVelocity = vc.getScaledMaximumFlingVelocity(); mFlingVelocity = vc.getScaledMinimumFlingVelocity(); mScroller = new OverScroller(context); mLeftEdge = new EdgeEffectCompat(context); mRightEdge = new EdgeEffectCompat(context); setWillNotDraw(false);/*from w ww. ja va 2s . c o m*/ setClipToPadding(false); }
From source file:com.evilduck.piano.views.instrument.PianoView.java
private void init() { if (!isInEditMode()) { scroller = new OverScroller(getContext()); gestureDetector = new GestureDetector(getContext(), gestureListener); scaleGestureDetector = new ScaleGestureDetector(getContext(), scaleGestureListener); }/* w w w . j a v a 2s .c o m*/ }
From source file:com.example.client.activity.imported.FlexibleSpaceWithImageWithViewPagerTab2Activity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_flexiblespacewithimagewithviewpagertab2); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); ViewCompat.setElevation(findViewById(R.id.header), getResources().getDimension(R.dimen.toolbar_elevation)); mPagerAdapter = new NavigationAdapter(getSupportFragmentManager()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mPagerAdapter);//w w w .j a v a 2 s . c o m mImageView = findViewById(R.id.image); mOverlayView = findViewById(R.id.overlay); // Padding for ViewPager must be set outside the ViewPager itself // because with padding, EdgeEffect of ViewPager become strange. mFlexibleSpaceHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height); mTabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height); findViewById(R.id.pager_wrapper).setPadding(0, mFlexibleSpaceHeight, 0, 0); mTitleView = (TextView) findViewById(R.id.title); mTitleView.setText(getTitle()); setTitle(null); SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs); slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1); slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(mPager); ((FrameLayout.LayoutParams) slidingTabLayout.getLayoutParams()).topMargin = mFlexibleSpaceHeight - mTabHeight; ViewConfiguration vc = ViewConfiguration.get(this); mSlop = vc.getScaledTouchSlop(); mMaximumVelocity = vc.getScaledMaximumFlingVelocity(); mInterceptionLayout = (TouchInterceptionFrameLayout) findViewById(R.id.container); mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener); mScroller = new OverScroller(getApplicationContext()); ScrollUtils.addOnGlobalLayoutListener(mInterceptionLayout, new Runnable() { @Override public void run() { // Extra space is required to move mInterceptionLayout when it's scrolled. // It's better to adjust its height when it's laid out // than to adjust the height when scroll events (onMoveMotionEvent) occur // because it causes lagging. // See #87: https://github.com/ksoichiro/Android-ObservableScrollView/issues/87 FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams(); lp.height = getScreenHeight() + mFlexibleSpaceHeight; mInterceptionLayout.requestLayout(); updateFlexibleSpace(); } }); }
From source file:com.emmaguy.todayilearned.PanView.java
public PanView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Sets up interactions mGestureDetector = new GestureDetector(context, new ScrollFlingGestureListener()); mScroller = new OverScroller(context); mEdgeEffectLeft = new EdgeEffect(context); mEdgeEffectTop = new EdgeEffect(context); mEdgeEffectRight = new EdgeEffect(context); mEdgeEffectBottom = new EdgeEffect(context); mDrawBlurredPaint = new Paint(); mDrawBlurredPaint.setDither(true);/* w ww. j a v a2s. co m*/ }
From source file:com.blestep.sportsbracelet.view.TimelineChartView.java
private void init(Context ctx, AttributeSet attrs, int defStyleAttr) { mUiHandler = new Handler(Looper.getMainLooper(), mMessenger); final Resources res = getResources(); final ViewConfiguration vc = ViewConfiguration.get(ctx); mTouchSlop = vc.getScaledTouchSlop() / 2; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mScroller = new OverScroller(ctx); int footerLabelColor = ContextCompat.getColor(getContext(), R.color.tlcStepsFooterLabelColor); int barItemBg = ContextCompat.getColor(getContext(), R.color.tlcStepsBarItemBg); int highlightBarItemBg = ContextCompat.getColor(getContext(), R.color.tlcStepsHighlightBarItemBg); mBarItemBgPaint = new Paint(); mBarItemBgPaint.setColor(barItemBg); mHighlightBarItemBgPaint = new Paint(); mHighlightBarItemBgPaint.setColor(highlightBarItemBg); mFooterBarHeight = res.getDimension(R.dimen.tlcDefFooterBarHeight); mViewAreaBgPaint = new Paint(); mGraphAreaBgPaint = new Paint(); mGraphAreaBgPaint.setColor(Color.TRANSPARENT); mFooterAreaBgPaint = new Paint(); mFooterAreaBgPaint.setColor(Color.TRANSPARENT); mGraphBottomLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mGraphBottomLinePaint.setColor(Color.WHITE); mGraphBottomLinePaint.setStrokeWidth(1); // /*from ww w .j a v a 2s .c o m*/ mGraphTargetDashedLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mGraphTargetDashedLinePaint.setStyle(Paint.Style.STROKE); mGraphTargetDashedLinePaint.setColor(Color.WHITE); mGraphTargetDashedLinePaint.setStrokeWidth(1); PathEffect pathEffect = new DashPathEffect(new float[] { 9, 3 }, 1); mGraphTargetDashedLinePaint.setPathEffect(pathEffect); // labelPaint?? mLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mLabelFgPaint.setColor(footerLabelColor); // DisplayMetrics dp = getResources().getDisplayMetrics(); // float labelSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, res.getDimension(R.dimen.tlcDefFooterLabelSize), dp); mLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize)); mHighlightLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mHighlightLabelFgPaint.setColor(Color.WHITE); mHighlightLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize)); mBarItemWidth = res.getDimension(R.dimen.tlcDefBarItemWidth); mBarItemSpace = res.getDimension(R.dimen.tlcDefBarItemSpace); mTopSpaceHeight = res.getDimension(R.dimen.tlcDefTopSpace); // SurfaceView requires a background if (getBackground() == null) { setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent)); } // Initialize stuff setupBackgroundHandler(); setupTickLabels(); // Initialize the drawing refs (this will be update when we have // the real size of the canvas) computeBoundAreas(); }
From source file:com.blestep.sportsbracelet.view.TimelineChartViewSleep.java
private void init(Context ctx, AttributeSet attrs, int defStyleAttr) { mUiHandler = new Handler(Looper.getMainLooper(), mMessenger); final Resources res = getResources(); final ViewConfiguration vc = ViewConfiguration.get(ctx); mTouchSlop = vc.getScaledTouchSlop() / 2; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mScroller = new OverScroller(ctx); int footerLabelColor = ContextCompat.getColor(getContext(), R.color.tlcSleepFooterLabelColor); int barItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepBarItemBg); int highlightBarItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepHighlightBarItemBg); int barDeepItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepBarDeepItemBg); int highlightBarDeepItemBg = ContextCompat.getColor(getContext(), R.color.tlcSleepHighlightBarDeepItemBg); mBarItemBgPaint = new Paint(); mBarItemBgPaint.setColor(barItemBg); mHighlightBarItemBgPaint = new Paint(); mHighlightBarItemBgPaint.setColor(highlightBarItemBg); mBarDeepItemBgPaint = new Paint(); mBarDeepItemBgPaint.setColor(barDeepItemBg); mHighlightBarDeepItemBgPaint = new Paint(); mHighlightBarDeepItemBgPaint.setColor(highlightBarDeepItemBg); mFooterBarHeight = res.getDimension(R.dimen.tlcDefFooterBarHeight); mViewAreaBgPaint = new Paint(); mGraphAreaBgPaint = new Paint(); mGraphAreaBgPaint.setColor(Color.TRANSPARENT); mFooterAreaBgPaint = new Paint(); mFooterAreaBgPaint.setColor(Color.TRANSPARENT); mGraphBottomLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mGraphBottomLinePaint.setColor(Color.WHITE); mGraphBottomLinePaint.setStrokeWidth(1); // labelPaint?? mLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mLabelFgPaint.setColor(footerLabelColor); // DisplayMetrics dp = getResources().getDisplayMetrics(); // float labelSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, res.getDimension(R.dimen.tlcDefFooterLabelSize), dp); mLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize)); mHighlightLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mHighlightLabelFgPaint.setColor(Color.WHITE); mHighlightLabelFgPaint.setTextSize(res.getDimension(R.dimen.tlcDefFooterLabelSize)); mBarItemWidth = res.getDimension(R.dimen.tlcDefBarItemWidth); mBarItemSpace = res.getDimension(R.dimen.tlcDefBarItemSpace); mTopSpaceHeight = res.getDimension(R.dimen.tlcDefTopSpace); // SurfaceView requires a background if (getBackground() == null) { setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent)); }/*from w ww. j a v a2 s. com*/ // Initialize stuff setupBackgroundHandler(); setupTickLabels(); // Initialize the drawing refs (this will be update when we have // the real size of the canvas) computeBoundAreas(); }
From source file:com.bitflake.counter.HorizontalPicker.java
public HorizontalPicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // create the selector wheel paint TextPaint paint = new TextPaint(); paint.setAntiAlias(true);/*from ww w . j a v a2 s . c om*/ textPaint = paint; TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.HorizontalPicker, defStyle, 0); CharSequence[] values; int ellipsize = 3; // END default value int sideItems = this.sideItems; try { textColor = a.getColorStateList(R.styleable.HorizontalPicker_android_textColor); if (textColor == null) { textColor = ColorStateList.valueOf(0xFF000000); } values = a.getTextArray(R.styleable.HorizontalPicker_values); ellipsize = a.getInt(R.styleable.HorizontalPicker_android_ellipsize, ellipsize); marqueeRepeatLimit = a.getInt(R.styleable.HorizontalPicker_android_marqueeRepeatLimit, marqueeRepeatLimit); dividerSize = a.getDimension(R.styleable.HorizontalPicker_dividerSize, dividerSize); sideItems = a.getInt(R.styleable.HorizontalPicker_sideItems, sideItems); float textSize = a.getDimension(R.styleable.HorizontalPicker_android_textSize, -1); if (textSize > -1) { setTextSize(textSize); } } finally { a.recycle(); } switch (ellipsize) { case 1: setEllipsize(TextUtils.TruncateAt.START); break; case 2: setEllipsize(TextUtils.TruncateAt.MIDDLE); break; case 3: setEllipsize(TextUtils.TruncateAt.END); break; case 4: setEllipsize(TextUtils.TruncateAt.MARQUEE); break; } Paint.FontMetricsInt fontMetricsInt = textPaint.getFontMetricsInt(); boringMetrics = new BoringLayout.Metrics(); boringMetrics.ascent = fontMetricsInt.ascent; boringMetrics.bottom = fontMetricsInt.bottom; boringMetrics.descent = fontMetricsInt.descent; boringMetrics.leading = fontMetricsInt.leading; boringMetrics.top = fontMetricsInt.top; boringMetrics.width = itemWidth; setWillNotDraw(false); flingScrollerX = new OverScroller(context); adjustScrollerX = new OverScroller(context, new DecelerateInterpolator(2.5f)); // initialize constants ViewConfiguration configuration = ViewConfiguration.get(context); touchSlop = configuration.getScaledTouchSlop(); mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); maximumFlingVelocity = configuration.getScaledMaximumFlingVelocity() / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT; overscrollDistance = configuration.getScaledOverscrollDistance(); previousScrollerX = Integer.MIN_VALUE; setValues(values); setSideItems(sideItems); touchHelper = new PickerTouchHelper(this); ViewCompat.setAccessibilityDelegate(this, touchHelper); }
From source file:kr.selfcontrol.selflocklauncher.picker.HorizontalPicker.java
public HorizontalPicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // create the selector wheel paint TextPaint paint = new TextPaint(); paint.setAntiAlias(true);// w w w . j a v a 2s . co m mTextPaint = paint; TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.HorizontalPicker, defStyle, 0); CharSequence[] values; int ellipsize = 3; // END default value int sideItems = mSideItems; try { mTextColor = a.getColorStateList(R.styleable.HorizontalPicker_android_textColor); if (mTextColor == null) { mTextColor = ColorStateList.valueOf(0xFF000000); } values = a.getTextArray(R.styleable.HorizontalPicker_values); ellipsize = a.getInt(R.styleable.HorizontalPicker_android_ellipsize, ellipsize); mMarqueeRepeatLimit = a.getInt(R.styleable.HorizontalPicker_android_marqueeRepeatLimit, mMarqueeRepeatLimit); mDividerSize = a.getDimension(R.styleable.HorizontalPicker_dividerSize, mDividerSize); sideItems = a.getInt(R.styleable.HorizontalPicker_sideItems, sideItems); float textSize = a.getDimension(R.styleable.HorizontalPicker_android_textSize, -1); if (textSize > -1) { setTextSize(textSize); } } finally { a.recycle(); } switch (ellipsize) { case 1: setEllipsize(TextUtils.TruncateAt.START); break; case 2: setEllipsize(TextUtils.TruncateAt.MIDDLE); break; case 3: setEllipsize(TextUtils.TruncateAt.END); break; case 4: setEllipsize(TextUtils.TruncateAt.MARQUEE); break; } Paint.FontMetricsInt fontMetricsInt = mTextPaint.getFontMetricsInt(); mBoringMetrics = new BoringLayout.Metrics(); mBoringMetrics.ascent = fontMetricsInt.ascent; mBoringMetrics.bottom = fontMetricsInt.bottom; mBoringMetrics.descent = fontMetricsInt.descent; mBoringMetrics.leading = fontMetricsInt.leading; mBoringMetrics.top = fontMetricsInt.top; mBoringMetrics.width = mItemWidth; setWillNotDraw(false); mFlingScrollerX = new OverScroller(context); mAdjustScrollerX = new OverScroller(context, new DecelerateInterpolator(2.5f)); // initialize constants ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity() / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT; mOverscrollDistance = configuration.getScaledOverscrollDistance(); mPreviousScrollerX = Integer.MIN_VALUE; setValues(values); setSideItems(sideItems); mTouchHelper = new PickerTouchHelper(this); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); }
From source file:com.lab47billion.appchooser.HorizontalPicker.java
public HorizontalPicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); _context = context;/*from ww w . ja va 2 s .c o m*/ // create the selector wheel paint TextPaint paint = new TextPaint(); paint.setAntiAlias(true); mTextPaint = paint; TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.HorizontalPicker, defStyle, 0); CharSequence[] values; int ellipsize = 3; // END default value int sideItems = mSideItems; try { mTextColor = a.getColorStateList(R.styleable.HorizontalPicker_android_textColor); if (mTextColor == null) { mTextColor = ColorStateList.valueOf(0xFF000000); } values = a.getTextArray(R.styleable.HorizontalPicker_values); ellipsize = a.getInt(R.styleable.HorizontalPicker_android_ellipsize, ellipsize); mDividerSize = a.getDimension(R.styleable.HorizontalPicker_dividerSize, mDividerSize); mNormalTextSize = a.getDimension(R.styleable.HorizontalPicker_normalTextSize, 20); mSelectedTextSize = a.getDimension(R.styleable.HorizontalPicker_selectedTextSize, -1); sideItems = a.getInt(R.styleable.HorizontalPicker_sideItems, sideItems); if (mNormalTextSize > -1) { setTextSize(mNormalTextSize); } if (mSelectedTextSize == -1) { mSelectedTextSize = mNormalTextSize; } } finally { a.recycle(); } switch (ellipsize) { case 1: setEllipsize(TextUtils.TruncateAt.START); break; case 2: setEllipsize(TextUtils.TruncateAt.MIDDLE); break; case 3: setEllipsize(TextUtils.TruncateAt.END); break; case 4: setEllipsize(TextUtils.TruncateAt.MARQUEE); break; } Paint.FontMetricsInt fontMetricsInt = mTextPaint.getFontMetricsInt(); mBoringMetrics = new BoringLayout.Metrics(); mBoringMetrics.ascent = fontMetricsInt.ascent; mBoringMetrics.bottom = fontMetricsInt.bottom; mBoringMetrics.descent = fontMetricsInt.descent; mBoringMetrics.leading = fontMetricsInt.leading; mBoringMetrics.top = fontMetricsInt.top; mBoringMetrics.width = mItemWidth; setWillNotDraw(false); mFlingScrollerX = new OverScroller(context); mAdjustScrollerX = new OverScroller(context, new DecelerateInterpolator(2.5f)); // initialize constants ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity() / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT; mOverscrollDistance = configuration.getScaledOverscrollDistance(); mPreviousScrollerX = Integer.MIN_VALUE; setValues(values); setSideItems(sideItems); /*mTouchHelper = new PickerTouchHelper(this); ViewCompat.setAccessibilityDelegate(this, mTouchHelper);*/ }