當前位置: 首頁>>代碼示例>>Java>>正文


Java Drawable.setHotspotBounds方法代碼示例

本文整理匯總了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;
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:36,代碼來源:SeekBarWidget.java

示例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);
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:60,代碼來源:Switch.java

示例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);
}
 
開發者ID:tranleduy2000,項目名稱:screenfilter,代碼行數:6,代碼來源:SeekBar.java

示例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);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:4,代碼來源:DrawableCompatLollipop.java

示例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);
		}
	}
}
 
開發者ID:rcketscientist,項目名稱:ToggleButtons,代碼行數:57,代碼來源:ToggleButton.java


注:本文中的android.graphics.drawable.Drawable.setHotspotBounds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。