@Override public void setAlpha(int alpha) { this.alpha = alpha; if (placeholder != null) { placeholder.setAlpha(alpha); } super.setAlpha(alpha); }
@Override public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { if (floatingItem != null) { floatingItem.setAlpha((int) (255 * floatingItemAlpha)); bgColor.setColor(floatingItemBgColor); c.drawRect(floatingItemBounds, bgColor); floatingItem.draw(c); } }
@Override public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { if (floatingItem != null) { floatingItem.setAlpha((int) (255 * floatingItemAlpha)); bgColor.setColor(floatingItemBgColor); c.drawRect(floatingItemBounds, bgColor); floatingItem.draw(c); } }
@Override public void draw(Canvas canvas) { if (!animating) { super.draw(canvas); } else { float normalized = (SystemClock.uptimeMillis() - startTimeMillis) / FADE_DURATION; if (normalized >= 1f) { animating = false; placeholder = null; super.draw(canvas); } else { if (placeholder != null) { placeholder.draw(canvas); } // setAlpha will call invalidateSelf and drive the animation. int partialAlpha = (int) (alpha * normalized); super.setAlpha(partialAlpha); super.draw(canvas); super.setAlpha(alpha); } } if (debugging) { drawDebugIndicator(canvas); } }
@Override public void setAlpha(int alpha) { mBubbleContentsDrawable.setAlpha(alpha); mBubbleArrowDrawable.setAlpha(alpha); }
Bitmap bit = some bitmap; BitmapDrawable bd; bd = new BitmapDrawable(bit); bd.setAlpha(128);
BitmapDrawable bd = new BitmapDrawable(convertColorIntoBlackAndWhiteImage(bMap)); bd.setAlpha(50); imageView1.setImageDrawable(bd);
BitmapDrawable bmpDrawable = new BitmapDrawable(getResources(), bitmap); bmpDrawable.setAlpha(150);
//bmp is your Bitmap object BitmapDrawable bd = new BitmapDrawable(bmp); bd.setAlpha(50); ImageView v = (ImageView) findViewById(R.id.image); v.setImageDrawable(bd);
BitmapDrawable drawable = new BitmapDrawable(getResources(), bitmap); drawable.setAlpha(100);
BitmapDrawable bd = new BitmapDrawable(bmp); bd.setAlpha(50); ImageView v = (ImageView) findViewById(R.id.image); v.setImageDrawable(bd);
@Override public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { if (floatingItem != null) { floatingItem.setAlpha((int) (255 * floatingItemAlpha)); bgColor.setColor(floatingItemBgColor); c.drawRect(floatingItemBounds, bgColor); floatingItem.draw(c); } }
@Override public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { if (floatingItem != null) { floatingItem.setAlpha((int) (255 * floatingItemAlpha)); bgColor.setColor(floatingItemBgColor); c.drawRect(floatingItemBounds, bgColor); floatingItem.draw(c); } }
private BitmapDrawable getHoveringListItem(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); view.draw(canvas); BitmapDrawable drawable = new BitmapDrawable(getResources(), bitmap); viewBounds = new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); drawable.setBounds(viewBounds); drawable.setAlpha(192); return drawable; }
// get the layer list being used as the background of 'container' View view = findViewById(R.id.container); LayerDrawable layer = (LayerDrawable)view.getBackground(); // get the first layer's BitmapDrawable by index BitmapDrawable bg = (BitmapDrawable)layer.getDrawable(0); // get the BitmapDrawable of the layer whose id is 'teste2' BitmapDrawable bgTeste2 = (BitmapDrawable)layer.findDrawableByLayerId(R.id.teste2); // do whatever you want with the drawable bg.setAlpha(60);
public void run() { BitmapDrawable bd = new BitmapDrawable(getResources(), src.getCover()); bd.setAlpha(128); ImageView bkg = (ImageView)findViewById(R.id.eventview_cover); bkg.setMaxHeight(getHeight());
public void setBackground(Activity activity) { if (mImageCache.size() != 0) { BitmapDrawable bd = new BitmapDrawable(activity.getResources(), mImageCache.get(KEY_CACHE_BLURRED_BACKGROUND_IMAGE)); bd.setAlpha(mAlpha); if (mFilterColor != -1) { bd.setColorFilter(mFilterColor, PorterDuff.Mode.DST_ATOP); } activity.getWindow().setBackgroundDrawable(bd); mImageCache.remove(KEY_CACHE_BLURRED_BACKGROUND_IMAGE); cacheBlurBehindAndExecuteTask = null; } }
LinearLayout layout = (LinearLayout) findViewById(R.id.testreportlinearlayout); Bitmap bmp = imgLoader.getBitmap(iconUrl); Bitmap blurredBmp = CommonUtils.blurBitmap(bmp, Constants.RADIUS); Bitmap scaledBmp = Bitmap.createScaledBitmap(blurredBmp, MAX_OF_NEW_XY, MAX_OF_NEW_XY, false); BitmapDrawable scaledBmpdrawable = new BitmapDrawable(getResources(), scaledBmp); scaledBmpdrawable.setAlpha(Constants.ALPHA); scaledBmpdrawable.setGravity(Gravity.CENTER); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { layout.setBackgroundDrawable(scaledBmpdrawable); } else { layout.setBackground(scaledBmpdrawable); }
mVirtBounds = getBounds(); mOrigBounds = mOuterBitmap.copyBounds(); mBoundsBoxBitmap.setAlpha(0); mBoundsBoxBitmap.setBounds(getVirtBounds()); SetInnerBounds();
private void drawEndGameState(Canvas canvas) { double alphaChange = 1; continueButtonEnabled = false; for (AnimationCell animation : game.aGrid.globalAnimation) { if (animation.getAnimationType() == MainGame.FADE_GLOBAL_ANIMATION) { alphaChange = animation.getPercentageDone(); } } BitmapDrawable displayOverlay = null; if (game.gameWon()) { if (game.canContinue()) { continueButtonEnabled = true; displayOverlay = winGameContinueOverlay; } else { displayOverlay = winGameFinalOverlay; } } else if (game.gameLost()) { displayOverlay = loseGameOverlay; } if (displayOverlay != null) { displayOverlay.setBounds(startingX, startingY, endingX, endingY); displayOverlay.setAlpha((int) (255 * alphaChange)); displayOverlay.draw(canvas); } }