List of usage examples for android.widget Scroller Scroller
public Scroller(Context context)
From source file:com.leeon.blank.widget.RangeBarNew.java
public RangeBarNew(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); applyConfig(context, attrs);/*from ww w . j a v a 2 s .c o m*/ mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(ViewConfiguration.get(context)); mPaddingRect = new Rect(); mLeftCursorRect = new Rect(); mRightCursorRect = new Rect(); mLeftIndicatorRect = new Rect(); mRightIndicatorRect = new Rect(); mPaddingRect.left = getPaddingLeft(); mPaddingRect.top = getPaddingTop(); mPaddingRect.right = getPaddingRight(); mPaddingRect.bottom = getPaddingBottom(); mRangeBarRect = new RectF(); mRangeBarRectSelected = new RectF(); if (mTextArray != null) { mTextWidthArray = new float[mTextArray.length]; } mLeftScroller = new Scroller(context); mRightScroller = new Scroller(context); initPaint(); initTextWidthArray(); setWillNotDraw(false); setFocusable(true); setClickable(true); }
From source file:com.jackie.refresh.RefreshLayoutBase.java
/** * @param context/*from w ww .j a v a 2 s .c o m*/ * @param attrs */ public RefreshLayoutBase(Context context, AttributeSet attrs) { super(context, attrs); // ? mScroller = new Scroller(context); // ?? mScreenHeight = context.getResources().getDisplayMetrics().heightPixels; // header?1/4 mHeaderHeight = mScreenHeight / 4; // ? initLayout(context); }
From source file:info.ipeanut.youngsamples.third.viewgroup.directionalViewPager.DirectionalViewPager.java
void initViewPager() { ///* w w w. j a v a 2s . co m*/ setWillNotDraw(false); mScroller = new Scroller(getContext()); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();//Fling mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); //crush // setPageTransformer(false,new DefaultTransformer()); }
From source file:com.xyczero.customswipelistview.CustomSwipeListView.java
private void initCustomSwipeListView() { final Context context = getContext(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop() * 5; mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); // set minimum velocity according to the MIN_VELOCITY. mMinimumVelocity = CustomSwipeUtils.convertDptoPx(context, MIN_VELOCITY); mScreenWidth = CustomSwipeUtils.getScreenWidth(context); mScroller = new Scroller(context); initSwipeItemTriggerDeltaX();//w w w .j a v a 2s. c om // set default value. mCurTouchSwipeMode = TOUCH_SWIPE_NONE; mSelectedPosition = INVALID_POSITION; }
From source file:com.zenithed.core.widget.scaledimageview.ScaledImageView.java
/** * Sets up gesture detection and finds the original image dimensions. Nothing else is done until onDraw() is called * because the view dimensions will normally be unknown when this method is called. *//* ww w.j av a 2s .c om*/ private void initialize(Context context) { mContext = context; mScroller = new Scroller(mContext); mZoomer = new Zoomer(mContext); mMovementGestureDetector = new GestureDetectorCompat(mContext, mMovementGestureListener); mScaleGestureDetector = new ScaleGestureDetector(mContext, mScaleGestureListener); // by default the view must be enabled since it doesn't contain any content. setEnabled(false); }
From source file:com.eccyan.widget.SpinningTabStrip.java
public SpinningTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/*from w w w.ja v a 2s .c om*/ setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); addView(tabsContainer); flingVelocity = new Scroller(getContext()); flinger = new Flinger(); gestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { flingVelocity.forceFinished(true); flingVelocity.fling(getScrollX(), getScrollY(), -(int) velocityX, -(int) velocityY, Integer.MIN_VALUE, Integer.MAX_VALUE, 0, getHeight()); scrollStopped.set(false); Log.d(TAG, "scroll fling started"); return true; } @Override public boolean onDown(MotionEvent e) { if (!flingVelocity.isFinished()) { flingVelocity.forceFinished(true); } if (!flinger.isFinished()) { flinger.forceFinished(true); } return super.onDown(e); } }); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize); ColorStateList colorStateList = a.getColorStateList(TEXT_COLOR_INDEX); int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, android.R.color.white); if (colorStateList != null) { tabTextColor = colorStateList; } else { tabTextColor = getColorStateList(textPrimaryColor); } underlineColor = textPrimaryColor; dividerColor = textPrimaryColor; indicatorColor = textPrimaryColor; // get custom attrs a = context.obtainStyledAttributes(attrs, R.styleable.SpinningTabStrip); indicatorColor = a.getColor(R.styleable.SpinningTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.SpinningTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.getColor(R.styleable.SpinningTabStrip_pstsDividerColor, dividerColor); dividerWidth = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsDividerWidth, dividerWidth); indicatorHeight = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.SpinningTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.SpinningTabStrip_pstsShouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.SpinningTabStrip_pstsScrollOffset, scrollOffset); textAllCaps = a.getBoolean(R.styleable.SpinningTabStrip_pstsTextAllCaps, textAllCaps); tabTypefaceStyle = a.getInt(R.styleable.SpinningTabStrip_pstsTextStyle, Typeface.BOLD); tabTypefaceSelectedStyle = a.getInt(R.styleable.SpinningTabStrip_pstsTextSelectedStyle, Typeface.BOLD); tabTextAlpha = a.getFloat(R.styleable.SpinningTabStrip_pstsTextAlpha, HALF_TRANSP); tabTextSelectedAlpha = a.getFloat(R.styleable.SpinningTabStrip_pstsTextSelectedAlpha, OPAQUE); a.recycle(); setMarginBottomTabContainer(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:com.viettel.image.zoom.ZoomViewPaper.java
void initViewPager() { setWillNotDraw(false);//from w w w .j ava 2 s. co m mScroller = new Scroller(getContext()); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:devicroft.burnboy.Activities.MainActivity.java
private void dispatchLicenseDialog() { Log.d(LOG_TAG, "dispatchLicenseDialog"); AlertDialog d = new AlertDialog.Builder(this).setTitle("Licenses") .setMessage(Html.fromHtml(getString(R.string.license_fab) + "<br><br>" + getString(R.string.license_mpandroidchart) + getString(R.string.app_name))) //https://stackoverflow.com/questions/3235131/set-textview-text-from-html-formatted-string-resource-in-xml .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss();/* www .ja v a 2s .c o m*/ } }).show(); TextView textView = (TextView) d.findViewById(android.R.id.message); textView.setScroller(new Scroller(this)); textView.setVerticalScrollBarEnabled(true); textView.setAllCaps(false); textView.setMovementMethod(new ScrollingMovementMethod()); }
From source file:com.example.nitish.welcomapp.widgetpt.PeriodicTableView.java
public PeriodicTableView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mSelectedPaint = new Paint(); mSelectedPaint.setAntiAlias(true);//from w w w .j av a 2 s.c o m mSelectedPaint.setStyle(Paint.Style.STROKE); mSelectedPaint.setStrokeJoin(Paint.Join.ROUND); mSelectedPaint.setColor(COLOR_SELECTED); mNumberPaint = new Paint(); mNumberPaint.setAntiAlias(true); mNumberPaint.setColor(COLOR_BLOCK_FOREGROUND); mSymbolPaint = new Paint(mNumberPaint); mSymbolPaint.setTextAlign(Paint.Align.CENTER); mTitlePaint = new Paint(mSymbolPaint); mHeaderPaint = new Paint(mSymbolPaint); mSmallTextPaint = new Paint(mSymbolPaint); mNumberPaint.setSubpixelText(true); mSmallTextPaint.setSubpixelText(true); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PeriodicTableView, defStyle, 0); mTitle = a.getText(R.styleable.PeriodicTableView_title); setFgColor(a.getColor(R.styleable.PeriodicTableView_fgColor, COLOR_DEFAULT_FOREGROUND)); setBgColor(a.getColor(R.styleable.PeriodicTableView_bgColor, COLOR_DEFAULT_BACKGROUND)); a.recycle(); mLegend = new PeriodicTableLegend(context); mScaleGestureDetector = new ScaleGestureDetector(context, getOnScaleGestureListener()); mGestureDetector = new GestureDetector(context, getOnGestureListener()); mZoomer = new Zoomer(context); mScroller = new Scroller(context); mEdgeEffectLeft = new EdgeEffectCompat(context); mEdgeEffectTop = new EdgeEffectCompat(context); mEdgeEffectRight = new EdgeEffectCompat(context); mEdgeEffectBottom = new EdgeEffectCompat(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mAccessibilityDelegate = new AccessibilityDelegate(this); ViewCompat.setAccessibilityDelegate(this, mAccessibilityDelegate); } }
From source file:net.simonvt.staggeredgridview.StaggeredGridView.java
public StaggeredGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StaggeredGridView, defStyle, 0); colCount = a.getInt(R.styleable.StaggeredGridView_android_numColumns, 1); verticalItemMargin = a.getDimensionPixelSize(R.styleable.StaggeredGridView_verticalItemMargin, 0); horizontalItemMargin = a.getDimensionPixelSize(R.styleable.StaggeredGridView_horizontalItemMargin, 0); selector = a.getDrawable(R.styleable.StaggeredGridView_android_listChoiceBackgroundIndicator); if (selector != null) { selector.setCallback(this); }//from w w w . j a va 2s.c o m a.recycle(); final ViewConfiguration vc = ViewConfiguration.get(context); touchSlop = vc.getScaledTouchSlop(); maximumVelocity = vc.getScaledMaximumFlingVelocity(); flingVelocity = vc.getScaledMinimumFlingVelocity(); scroller = new Scroller(context); topEdge = new EdgeEffect(context); bottomEdge = new EdgeEffect(context); setWillNotDraw(false); setClipToPadding(false); setVerticalScrollBarEnabled(true); }