List of usage examples for android.graphics.drawable Drawable getOpacity
public abstract @PixelFormat.Opacity int getOpacity();
From source file:Main.java
private static Bitmap drawableToBitMap(Drawable drawable) { if (drawable == null) { return null; }//from ww w. j a v a 2 s . com 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; } }
From source file:com.dv.Utils.Tools.java
/** * BitMap/*from www . ja v a 2 s . c o m*/ * * @param drawable * @return */ 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; }
From source file:uk.ac.kent.jb509.shopper.utils.SlidingUpPanelLayout.java
private static boolean hasOpaqueBackground(final View v) { final Drawable bg = v.getBackground(); if (bg != null) { return bg.getOpacity() == PixelFormat.OPAQUE; }// ww w.j a va 2 s . com return false; }
From source file:com.aigo.kt03airdemo.ui.view.ResideLayout.java
private static boolean viewIsOpaque(View v) { if (ViewCompat.isOpaque(v)) 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(); return bg != null && bg.getOpacity() == PixelFormat.OPAQUE; }
From source file:com.bright.cloudutils.view.ResideLayout.java
private static boolean viewIsOpaque(View v) { if (ViewCompat.isOpaque(v)) return true; // View#isOpaque didn't take all valid opaque scrollbar modes into // account//from w w w. j a v a 2s.c om // 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(); return bg != null && bg.getOpacity() == PixelFormat.OPAQUE; }
From source file:android.support.v17.leanback.app.ErrorSupportFragment.java
/** * Sets a drawable for the fragment background. * * @param drawable The drawable used for the background. *//*ww w . ja v a 2 s . c om*/ public void setBackgroundDrawable(Drawable drawable) { mBackgroundDrawable = drawable; if (drawable != null) { final int opacity = drawable.getOpacity(); mIsBackgroundTranslucent = (opacity == PixelFormat.TRANSLUCENT || opacity == PixelFormat.TRANSPARENT); } updateBackground(); updateMessage(); }
From source file:com.android.dialer.widget.OverlappingPaneLayout.java
private static boolean viewIsOpaque(View v) { if (ViewCompat.isOpaque(v)) return true; final Drawable bg = v.getBackground(); if (bg != null) { return bg.getOpacity() == PixelFormat.OPAQUE; }//from w w w . ja v a 2 s. c o m return false; }
From source file:android.car.ui.provider.CarDrawerLayout.java
private static boolean hasOpaqueBackground(View v) { final Drawable bg = v.getBackground(); return bg != null && bg.getOpacity() == PixelFormat.OPAQUE; }
From source file:cn.emagsoftware.ui.BugFixedSlidingPaneLayout.java
private static boolean viewIsOpaque(View v) { if (ViewCompat.isOpaque(v)) 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; }//from w w w .ja v a2s .c o m return false; }
From source file:com.waz.zclient.pages.main.conversationpager.SlidingPaneLayout.java
private static boolean viewIsOpaque(View v) { if (ViewCompat.isOpaque(v)) { return true; }/* w ww. ja va 2 s . co m*/ // 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; }