本文整理匯總了Java中android.graphics.drawable.Drawable.getClass方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.getClass方法的具體用法?Java Drawable.getClass怎麽用?Java Drawable.getClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.Drawable
的用法示例。
在下文中一共展示了Drawable.getClass方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onDraw
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
protected void onDraw(Canvas canvas) {
Drawable drawable = getDrawable();
if (drawable != null && getWidth() != 0 && getHeight() != 0) {
measure(0, 0);
if (drawable.getClass() != NinePatchDrawable.class) {
int radius;
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap().copy(Config.ARGB_8888, true);
if (this.defaultWidth == 0) {
this.defaultWidth = getWidth();
}
if (this.defaultHeight == 0) {
this.defaultHeight = getHeight();
}
int i = this.mBorderInsideColor;
getClass();
if (i != -1) {
i = this.mBorderOutsideColor;
getClass();
if (i != -1) {
radius = ((this.defaultWidth < this.defaultHeight ? this.defaultWidth : this.defaultHeight) / 2) - (this.mBorderThickness * 2);
drawCircleBorder(canvas, (this.mBorderThickness / 2) + radius, this.mBorderInsideColor);
drawCircleBorder(canvas, (this.mBorderThickness + radius) + (this.mBorderThickness / 2), this.mBorderOutsideColor);
canvas.drawBitmap(getCroppedRoundBitmap(bitmap, radius), (float) ((this.defaultWidth / 2) - radius), (float) ((this.defaultHeight / 2) - radius), null);
}
}
i = this.mBorderInsideColor;
getClass();
if (i != -1) {
i = this.mBorderOutsideColor;
getClass();
if (i == -1) {
radius = ((this.defaultWidth < this.defaultHeight ? this.defaultWidth : this.defaultHeight) / 2) - this.mBorderThickness;
drawCircleBorder(canvas, (this.mBorderThickness / 2) + radius, this.mBorderInsideColor);
canvas.drawBitmap(getCroppedRoundBitmap(bitmap, radius), (float) ((this.defaultWidth / 2) - radius), (float) ((this.defaultHeight / 2) - radius), null);
}
}
i = this.mBorderInsideColor;
getClass();
if (i == -1) {
i = this.mBorderOutsideColor;
getClass();
if (i != -1) {
radius = ((this.defaultWidth < this.defaultHeight ? this.defaultWidth : this.defaultHeight) / 2) - this.mBorderThickness;
drawCircleBorder(canvas, (this.mBorderThickness / 2) + radius, this.mBorderOutsideColor);
canvas.drawBitmap(getCroppedRoundBitmap(bitmap, radius), (float) ((this.defaultWidth / 2) - radius), (float) ((this.defaultHeight / 2) - radius), null);
}
}
radius = (this.defaultWidth < this.defaultHeight ? this.defaultWidth : this.defaultHeight) / 2;
canvas.drawBitmap(getCroppedRoundBitmap(bitmap, radius), (float) ((this.defaultWidth / 2) - radius), (float) ((this.defaultHeight / 2) - radius), null);
}
}
}
示例2: onDraw
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
Drawable drawable = getDrawable();
if (drawable == null) {
return;
}
if (getWidth() == 0 || getHeight() == 0) {
return;
}
this.measure(0, 0);
if (drawable.getClass() == NinePatchDrawable.class)
return;
Bitmap b = ((BitmapDrawable) drawable).getBitmap();
Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true);
if (defaultWidth == 0) {
defaultWidth = getWidth();
}
if (defaultHeight == 0) {
defaultHeight = getHeight();
}
int radius = 0;
if (mBorderInsideColor != defaultColor
&& mBorderOutsideColor != defaultColor) {// 定義畫兩個邊框,分別為外圓邊框和內圓邊框
radius = (defaultWidth < defaultHeight ? defaultWidth
: defaultHeight) / 2 - 2 * mBorderThickness;
// 畫內圓
drawCircleBorder(canvas, radius + mBorderThickness / 2,
mBorderInsideColor);
// 畫外圓
drawCircleBorder(canvas, radius + mBorderThickness
+ mBorderThickness / 2, mBorderOutsideColor);
} else if (mBorderInsideColor != defaultColor
&& mBorderOutsideColor == defaultColor) {// 定義畫一個邊框
radius = (defaultWidth < defaultHeight ? defaultWidth
: defaultHeight) / 2 - mBorderThickness;
drawCircleBorder(canvas, radius + mBorderThickness / 2,
mBorderInsideColor);
} else if (mBorderInsideColor == defaultColor
&& mBorderOutsideColor != defaultColor) {// 定義畫一個邊框
radius = (defaultWidth < defaultHeight ? defaultWidth
: defaultHeight) / 2 - mBorderThickness;
drawCircleBorder(canvas, radius + mBorderThickness / 2,
mBorderOutsideColor);
} else {// 沒有邊框
radius = (defaultWidth < defaultHeight ? defaultWidth
: defaultHeight) / 2;
}
Bitmap roundBitmap = getCroppedRoundBitmap(bitmap, radius);
canvas.drawBitmap(roundBitmap, defaultWidth / 2 - radius, defaultHeight
/ 2 - radius, null);
}