本文整理了Java中android.graphics.drawable.Drawable.getOpacity()
方法的一些代码示例,展示了Drawable.getOpacity()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Drawable.getOpacity()
方法的具体详情如下:
包路径:android.graphics.drawable.Drawable
类名称:Drawable
方法名:getOpacity
暂无
代码示例来源:origin: bumptech/glide
@Override
public int getOpacity() {
return wrapped.getOpacity();
}
代码示例来源:origin: facebook/litho
@Override
public int getOpacity() {
return mDrawable.getOpacity();
}
代码示例来源:origin: facebook/litho
@Override
public int getOpacity() {
return mDrawable == null ? UNSET : mDrawable.getOpacity();
}
代码示例来源:origin: rey5137/material
@Override
public int getOpacity() {
return mDrawable != null ? mDrawable.getOpacity() : PixelFormat.UNKNOWN;
}
代码示例来源:origin: facebook/litho
@Override
public int getOpacity() {
return mDrawable.getOpacity();
}
代码示例来源:origin: seven332/EhViewer
@Override
public int getOpacity() {
if (mDrawable != null) {
return mDrawable.getOpacity();
} else {
return PixelFormat.UNKNOWN;
}
}
代码示例来源:origin: seven332/EhViewer
public int getOpacity() {
return this.mDrawable.getOpacity();
}
代码示例来源:origin: umano/AndroidSlidingUpPanel
private static boolean hasOpaqueBackground(View v) {
final Drawable bg = v.getBackground();
return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}
代码示例来源:origin: naman14/Timber
private static boolean hasOpaqueBackground(View v) {
final Drawable bg = v.getBackground();
return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}
代码示例来源:origin: android-hacker/VirtualXposed
public static Bitmap drawableToBitmap(Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = ((BitmapDrawable) drawable);
return bitmapDrawable.getBitmap();
} else {
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}
}
代码示例来源:origin: android-hacker/VirtualXposed
private static Bitmap drawableToBitMap(Drawable drawable) {
if (drawable == null) {
return null;
}
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = ((BitmapDrawable) drawable);
return bitmapDrawable.getBitmap();
} else {
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}
}
代码示例来源:origin: WVector/AppUpdate
public static Bitmap drawableToBitmap(Drawable drawable) {
Bitmap bitmap = Bitmap.createBitmap(
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
: Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
//canvas.setBitmap(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}
代码示例来源:origin: android-hacker/VirtualXposed
public static Bitmap drawableToBitMap(Drawable drawable) {
if (drawable == null) {
return null;
}
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = ((BitmapDrawable) drawable);
return bitmapDrawable.getBitmap();
} else {
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}
}
}
代码示例来源:origin: smuyyh/BookReader
private static Bitmap drawable2Bitmap(Drawable drawable) {
if (drawable == null) {
return null;
}
// 取 drawable 的长宽
int w = drawable.getIntrinsicWidth();
int h = drawable.getIntrinsicHeight();
// 取 drawable 的颜色格式
Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE
? Bitmap.Config.ARGB_8888
: Bitmap.Config.RGB_565;
// 建立对应 bitmap
Bitmap bitmap = Bitmap.createBitmap(w, h, config);
// 建立对应 bitmap 的画布
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, w, h);
// 把 drawable 内容画到画布中
drawable.draw(canvas);
return bitmap;
}
代码示例来源:origin: cymcsg/UltimateAndroid
public static Bitmap drawableToBitmap(Drawable drawable) {
if (null == drawable) {
return null;
}
Bitmap bitmap = Bitmap
.createBitmap(
drawable.getIntrinsicWidth() / 2,
drawable.getIntrinsicHeight() / 2,
drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888
: Config.RGB_565
);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth() / 2, drawable.getIntrinsicHeight() / 2);
drawable.draw(canvas);
return bitmap;
}
代码示例来源:origin: cymcsg/UltimateAndroid
public static Bitmap drawableToBitmapOriginal(Drawable drawable) {
if (null == drawable) {
return null;
}
Bitmap bitmap = Bitmap
.createBitmap(
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888
: Config.RGB_565
);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
private static Bitmap drawable2Bitmap(Drawable drawable) {
if (drawable == null) {
return null;
}
// 取 drawable 的长宽
int w = drawable.getIntrinsicWidth();
int h = drawable.getIntrinsicHeight();
// 取 drawable 的颜色格式
Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
: Bitmap.Config.RGB_565;
// 建立对应 bitmap
Bitmap bitmap = Bitmap.createBitmap(w, h, config);
// 建立对应 bitmap 的画布
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, w, h);
// 把 drawable 内容画到画布中
drawable.draw(canvas);
return bitmap;
}
代码示例来源:origin: chentao0707/SimplifyReader
/**
* Sets the drawable that will be drawn between each item in the list. If the drawable does
* not have an intrinsic height, you should also call {@link #setDividerHeight(int)}
*
* @param divider The drawable to use.
*/
public void setDivider(Drawable divider) {
if (divider != null) {
mDividerHeight = divider.getIntrinsicHeight();
mClipDivider = divider instanceof ColorDrawable;
} else {
mDividerHeight = 0;
mClipDivider = false;
}
mDivider = divider;
mDividerIsOpaque = divider == null || divider.getOpacity() == PixelFormat.OPAQUE;
requestLayoutIfNecessary();
}
代码示例来源:origin: bingoogolapple/BGASwipeBackLayout-Android
private static boolean viewIsOpaque(View v) {
if (v.isOpaque()) {
return true;
}
// View#isOpaque didn't take all valid opaque scrollbar modes into account
// before API 18 (JB-MR2). On newer devices rely solely on isOpaque above and return false
// here. On older devices, check the view's background drawable directly as a fallback.
if (Build.VERSION.SDK_INT >= 18) {
return false;
}
final Drawable bg = v.getBackground();
if (bg != null) {
return bg.getOpacity() == PixelFormat.OPAQUE;
}
return false;
}
代码示例来源:origin: square/assertj-android
public S hasOpacity(int opacity) {
isNotNull();
int actualOpacity = actual.getOpacity();
assertThat(actualOpacity) //
.overridingErrorMessage("Expected opacity <%s> but was <%s>.", opacity, actualOpacity) //
.isEqualTo(opacity);
return myself;
}
内容来源于网络,如有侵权,请联系作者删除!