List of usage examples for android.graphics.drawable Drawable setHotspotBounds
public void setHotspotBounds(int left, int top, int right, int bottom)
From source file:net.qiujuer.genius.ui.compat.UiCompat.java
/** * As our DiscreteSeekBar implementation uses a circular drawable on API < 21 * we want to use the same method to set its bounds as the Ripple's hotspot bounds. * * @param drawable Drawable/*from w w w . ja v a 2 s . co m*/ * @param left Left * @param top Top * @param right Right * @param bottom Bottom */ public static void setHotspotBounds(Drawable drawable, int left, int top, int right, int bottom) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //We don't want the full size rect, Lollipop ripple would be too big int size = (right - left) / 8; drawable.setHotspotBounds(left + size, top + size, right - size, bottom - size); } else { drawable.setBounds(left, top, right, bottom); } }
From source file:me.henrytao.mdcore.widgets.internal.MdCheckBox.java
@Override protected void onDraw(Canvas canvas) { if (isLayoutRtl()) { canvas.translate(-mPaddingRight, 0); } else {// w w w . j a v a 2s . com canvas.translate(mPaddingLeft, 0); } super.onDraw(canvas); Drawable background = getBackground(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && background != null) { boolean isLayoutRtl = isLayoutRtl(); Rect bounds = background.getBounds(); int top = bounds.top; int bottom = bounds.bottom; int left = (isLayoutRtl ? getWidth() - mMinWidth : 0) + (!mHasCustomDrawable && !isLayoutRtl ? mPaddingLeft : 0); int right = (isLayoutRtl ? getWidth() : mMinWidth) - (!mHasCustomDrawable && isLayoutRtl ? mPaddingRight : 0); background.setHotspotBounds(left, top, right, bottom); } }
From source file:org.telegram.ui.Components.Switch.java
@Override public void draw(Canvas c) { final Rect padding = mTempRect; final int switchLeft = mSwitchLeft; final int switchTop = mSwitchTop; final int switchRight = mSwitchRight; final int switchBottom = mSwitchBottom; int thumbInitialLeft = switchLeft + getThumbOffset(); final Insets thumbInsets; if (mThumbDrawable != null) { thumbInsets = Insets.NONE; } else {//from ww w.j a va 2 s . c o m thumbInsets = Insets.NONE; } if (mTrackDrawable != null) { mTrackDrawable.getPadding(padding); thumbInitialLeft += padding.left; int trackLeft = switchLeft; int trackTop = switchTop; int trackRight = switchRight; int trackBottom = switchBottom; if (thumbInsets != Insets.NONE) { if (thumbInsets.left > padding.left) { trackLeft += thumbInsets.left - padding.left; } if (thumbInsets.top > padding.top) { trackTop += thumbInsets.top - padding.top; } if (thumbInsets.right > padding.right) { trackRight -= thumbInsets.right - padding.right; } if (thumbInsets.bottom > padding.bottom) { trackBottom -= thumbInsets.bottom - padding.bottom; } } mTrackDrawable.setBounds(trackLeft, trackTop, trackRight, trackBottom); } if (mThumbDrawable != null) { mThumbDrawable.getPadding(padding); final int thumbLeft = thumbInitialLeft - padding.left; final int thumbRight = thumbInitialLeft + mThumbWidth + padding.right; int offset = (AndroidUtilities.density == 1.5f ? AndroidUtilities.dp(1) : 0); mThumbDrawable.setBounds(thumbLeft, switchTop + offset, thumbRight, switchBottom + offset); final Drawable background = getBackground(); if (background != null && Build.VERSION.SDK_INT >= 21) { background.setHotspotBounds(thumbLeft, switchTop, thumbRight, switchBottom); } } super.draw(c); }
From source file:cnedu.ustcjd.widget.MultiSlider.java
private void setHotspot(float x, float y, Thumb thumb) { if (thumb == null || thumb.getThumb() == null) return;/*from w w w .j av a 2 s.c o m*/ final Drawable background = getBackground(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && background != null) { background.setHotspot(x, y); Rect rect = thumb.getThumb().getBounds(); final int offsetY = getPaddingTop(); background.setHotspotBounds(rect.left, rect.top + offsetY, rect.right, rect.bottom + offsetY); } }
From source file:com.albedinsky.android.ui.widget.SeekBarWidget.java
/** *//*from ww w.j av a 2 s . co m*/ @Override @SuppressLint("NewApi") public boolean onTouchEvent(@NonNull MotionEvent event) { final boolean processed = super.onTouchEvent(event); final int progress = getProgress(); if (processed) { if (progress != mProgress) { this.handleProgressChange(progress); } this.ensureDecorator(); switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: if (mDecorator.hasPrivateFlag(PFLAG_DISCRETE_PREVIEW_ENABLED)) { this.revealDiscreteComponents(); } break; case MotionEvent.ACTION_MOVE: final Drawable background = getBackground(); if (background != null && mAnimations.shouldDraw() && UiConfig.MATERIALIZED) { // Cancel the revealed circle around the thumb. background.setHotspotBounds(0, 0, 0, 0); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: if (mDecorator.hasPrivateFlag(PFLAG_DISCRETE_PREVIEW_ENABLED)) { this.concealDiscreteComponents(); } break; } } return processed; }