List of usage examples for android.graphics.drawable LayerDrawable setDrawableByLayerId
public boolean setDrawableByLayerId(int id, Drawable drawable)
From source file:com.github.dfa.diaspora_android.ui.BadgeDrawable.java
public static void setBadgeCount(Context context, LayerDrawable icon, String count) { BadgeDrawable badge;//from w w w . j av a 2 s . c o m // Reuse drawable if possible Drawable reuse = icon.findDrawableByLayerId(R.id.ic_badge); if (reuse != null && reuse instanceof BadgeDrawable) { badge = (BadgeDrawable) reuse; } else { badge = new BadgeDrawable(context); } badge.setCount(count); icon.mutate(); icon.setDrawableByLayerId(R.id.ic_badge, badge); }
From source file:uk.co.brightec.ratetheapp.RateTheApp.java
private void initStars() { Drawable selected = ContextCompat.getDrawable(getContext(), mDrawableResSelected); selected = selected.mutate();//from www . j ava 2 s. c o m selected.setColorFilter(new PorterDuffColorFilter(mSelectedStarColour, PorterDuff.Mode.SRC_ATOP)); Drawable unselected = ContextCompat.getDrawable(getContext(), mDrawableResUnSelected); unselected = unselected.mutate(); unselected.setColorFilter(new PorterDuffColorFilter(mUnselectedStarColour, PorterDuff.Mode.SRC_ATOP)); LayerDrawable ld = (LayerDrawable) mRatingBar.getProgressDrawable(); ld.setDrawableByLayerId(android.R.id.background, unselected); ld.setDrawableByLayerId(android.R.id.secondaryProgress, unselected); ld.setDrawableByLayerId(android.R.id.progress, selected); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mRatingBar.setProgressDrawableTiled(ld); } else { Drawable tiledDrawable = tileify(ld, false); mRatingBar.setProgressDrawable(tiledDrawable); } }
From source file:com.crazymin2.retailstore.ui.BaseActivity.java
public void setBadgeCount(Context context, LayerDrawable icon, int count) { MenuCounterDrawable badge;/* w ww . j a v a 2 s . c om*/ // Reuse drawable if possible Drawable reuse = icon.findDrawableByLayerId(R.id.ic_badge); if (reuse != null && reuse instanceof MenuCounterDrawable) { badge = (MenuCounterDrawable) reuse; } else { badge = new MenuCounterDrawable(context); } badge.setCount(count); icon.mutate(); icon.setDrawableByLayerId(R.id.ic_badge, badge); }
From source file:com.fabernovel.alertevoirie.ReportDetailsActivity.java
private void setPictureToImageView(String pictureName, ImageView imageView) { Bitmap picture = null;/*from ww w . java 2s. c o m*/ try { InputStream in = openFileInput(pictureName); picture = BitmapFactory.decodeStream(in); in.close(); LayerDrawable d = (LayerDrawable) getResources().getDrawable(R.drawable.editable_picture_frame); if (picture.getHeight() > picture.getWidth()) { Matrix m = new Matrix(); m.postRotate(-90); picture = Bitmap.createBitmap(picture, 0, 0, picture.getWidth(), picture.getHeight(), m, true); } picture = Bitmap.createScaledBitmap(picture, d.getIntrinsicWidth(), d.getIntrinsicHeight(), true); d.setDrawableByLayerId(R.id.picture, new BitmapDrawable(picture)); imageView.setImageDrawable(d); if (!hasPic) hasPic = (imageView.getId() == R.id.ImageView_far); // WTF ? // if (hasPic && (imageView.getId() == R.id.ImageView_far)) { // loadZoom(); // } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }