本文整理匯總了Java中android.graphics.drawable.Drawable.setHotspotBounds方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.setHotspotBounds方法的具體用法?Java Drawable.setHotspotBounds怎麽用?Java Drawable.setHotspotBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.Drawable
的用法示例。
在下文中一共展示了Drawable.setHotspotBounds方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTouchEvent
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
*/
@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;
}
示例2: draw
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@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 {
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);
}
示例3: setHotspotBounds
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public static void setHotspotBounds(Drawable drawable, int left, int top, int right, int bottom) {
//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);
}
示例4: setHotspotBounds
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public static void setHotspotBounds(Drawable drawable, int left, int top, int right, int bottom) {
drawable.setHotspotBounds(left, top, right, bottom);
}
示例5: onDraw
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
// If there's text of any sort resort to CompoundButton#onDraw
if (getText() != null && getText().length() > 0 ||
getTextOff() != null && getTextOff().length() > 0 ||
getTextOff() != null && getTextOn().length() > 0) {
super.onDraw(canvas);
}
// Otherwise override CompoundButton#onDraw entirely to allow properly aligned image toggles
else {
final Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable(this);
if (buttonDrawable != null) {
final int verticalGravity = getGravity() & Gravity.VERTICAL_GRAVITY_MASK;
final int horizontalGravity = getGravity() & Gravity.HORIZONTAL_GRAVITY_MASK;
final int drawableHeight = buttonDrawable.getIntrinsicHeight();
final int drawableWidth = buttonDrawable.getIntrinsicWidth();
final int top;
switch (verticalGravity) {
case Gravity.BOTTOM:
top = getHeight() - drawableHeight;
break;
case Gravity.CENTER_VERTICAL:
top = (getHeight() - drawableHeight) / 2;
break;
default:
top = 0;
}
final int left;
switch (horizontalGravity) {
case Gravity.RIGHT:
case Gravity.END:
left = getWidth() - drawableWidth;
break;
case Gravity.CENTER_HORIZONTAL:
left = (getWidth() - drawableWidth) / 2;
break;
default:
left = 0;
}
final int bottom = top + drawableHeight;
final int right = left + drawableWidth;
buttonDrawable.setBounds(left, top, right, bottom);
final Drawable background = getBackground();
if (Build.VERSION.SDK_INT > 21 && background != null) {
background.setHotspotBounds(left, top, right, bottom);
}
buttonDrawable.draw(canvas);
}
}
}