List of usage examples for android.graphics.drawable ScaleDrawable ScaleDrawable
public ScaleDrawable(Drawable drawable, int gravity, float scaleWidth, float scaleHeight)
From source file:com.ceino.chaperonandroid.activities.LicenseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ChaperOnApplication.get(this).inject(this); chaperOnConnection = new ChaperOnConnection(this); overridePendingTransition(R.anim.animation, R.anim.animation2); setContentView(R.layout.activity_licenseverify); ButterKnife.inject(this); toastHandler = new ToastHandler(this); Intent intent = getIntent();//from w w w . j a va2s . co m phone = intent.getStringExtra("phone"); email = intent.getStringExtra("email"); password = intent.getStringExtra("pwd"); firstname = intent.getStringExtra("fname"); username = intent.getStringExtra("uname"); imagePath = intent.getStringExtra("imgpath"); street = intent.getStringExtra("street"); apartment = intent.getStringExtra("aptno"); city = intent.getStringExtra("city"); postal = intent.getStringExtra("postal"); country = intent.getStringExtra("country"); lastname = intent.getStringExtra("lname"); description = intent.getStringExtra("desc"); rideType = intent.getIntExtra("ridetype", 0); lattitude = intent.getDoubleExtra("lat", 0); longtitude = intent.getDoubleExtra("long", 0); Drawable drawable = getResources().getDrawable(R.drawable.hash); drawable.setBounds(0, 0, (int) (drawable.getIntrinsicWidth() * 0.4), (int) (drawable.getIntrinsicHeight() * 0.4)); ScaleDrawable sd = new ScaleDrawable(drawable, 0, 1f, 1f); emptySeats.setCompoundDrawablePadding(15); emptySeats.setCompoundDrawables(sd.getDrawable(), null, null, null); imgBack.setOnClickListener(this); imgLicense.setOnClickListener(this); saveAllbtn.setOnClickListener(this); }
From source file:com.landenlabs.all_UiDemo.frag.ImageScalesFrag.java
private void setScaledVector(ImageView imageView, int imageRes) { Drawable rawDrawable;// w w w . j a v a 2s . c o m if (Build.VERSION.SDK_INT >= 21) { rawDrawable = getResources().getDrawable(imageRes, getTheme()); } else { rawDrawable = getResources().getDrawable(imageRes); } Drawable drawable = rawDrawable.mutate(); /* int pad = 50; drawable.setBounds(0, pad, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); */ // ScaleDrawable does nothing !!!! if (false) { ScaleDrawable scaleDrawable = new ScaleDrawable(rawDrawable, Gravity.TOP | Gravity.LEFT, 2.0f, 0.8f); scaleDrawable.setLevel(8000); drawable = scaleDrawable.getDrawable(); } if (false) { int tintColor = 0x80ff0000; ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] {} }, new int[] { tintColor }); drawable = DrawableCompat.wrap(drawable.mutate()); DrawableCompat.setTintList(drawable, colorStateList); DrawableCompat.setTintMode(drawable, PorterDuff.Mode.MULTIPLY); } //imageView.setScaleType(ImageView.ScaleType.CENTER); imageView.setImageDrawable(drawable); // imageView.setImageDrawable(null); // imageView.setBackgroundDrawable(drawable); }
From source file:co.ceryle.segmentedbutton.SegmentedButton.java
/** * @param scale sets button's drawable size. It multiplies drawable's width and height with the given variable. *///from w ww. jav a 2s. c o m public void scaleDrawable(double scale) { Drawable[] drawables = getCompoundDrawables(); for (int i = 0; i < drawables.length; i++) { if (drawables[i] != null) { if (drawables[i] instanceof ScaleDrawable) { drawables[i].setLevel(1); } ScaleDrawable sd = new ScaleDrawable(drawables[i], 0, drawables[i].getIntrinsicWidth(), drawables[i].getIntrinsicHeight()); drawables[i].setBounds(0, 0, (int) (drawables[i].getIntrinsicWidth() * scale), (int) (drawables[i].getIntrinsicHeight() * scale)); setDrawable(sd.getDrawable(), i); } } }
From source file:com.pranavpandey.smallapp.theme.DynamicTheme.java
/** * Create a scaled drawable to use it properly as dialog icon. * It will also remove the issue of too big dialog icon. * * @param context to retrieve resources. * @param drawable to scale./* ww w. java2s .c o m*/ * * @return Scaled drawable to use as dialog icon. */ public static Drawable createDialogIcon(Context context, @NonNull Drawable drawable) { int widthHeight = context.getResources().getDimensionPixelSize(R.dimen.sas_dialog_icon_size); return new ScaleDrawable(drawable, 0, widthHeight, widthHeight).getDrawable(); }
From source file:com.landenlabs.all_UiDemo.frag.ImageScalesFrag.java
private Bitmap setScaledImage(final Drawable bgImage, View view, Bitmap prevScaled) { if (bgImage != null) { if (prevScaled != null) prevScaled.recycle();//from w w w . j a va 2s .com int screenWidthPx = Resources.getSystem().getDisplayMetrics().widthPixels; int viewHeightPx = view.getMeasuredHeight(); // view.setBackgroundResource(bgImage); if (bgImage instanceof BitmapDrawable) { BitmapDrawable bmDrawable = (BitmapDrawable) bgImage; Bitmap bmImage = bmDrawable.getBitmap(); prevScaled = scaleCenterCrop(bmImage, screenWidthPx, viewHeightPx); view.setBackgroundDrawable(new BitmapDrawable(prevScaled)); } else { // TODO - compute scale factor from screenWidthPx and viewHeightx Drawable scaleDrawable = new ScaleDrawable(bgImage, Gravity.NO_GRAVITY, 1.0f, 0.1f); view.setBackgroundDrawable(scaleDrawable); } } return prevScaled; }
From source file:org.ciasaboark.tacere.manager.NotificationManagerWrapper.java
private Bitmap combineDrawablesToBitmap(final Drawable backgroundImage, final BitmapDrawable overlayImage, int width, int height) { Bitmap canvasBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); // Create a canvas, that will draw on to canvasBitmap. Canvas imageCanvas = new Canvas(canvasBitmap); // Draw the image to our canvas backgroundImage.setBounds(0, 0, width, height); backgroundImage.draw(imageCanvas);/* w w w . ja va2 s . com*/ overlayImage.setBounds(0, 0, (int) (overlayImage.getIntrinsicWidth() * 0.5), (int) (overlayImage.getIntrinsicHeight() * 0.5)); final int scaleWidth = 24; final int scaleHeight = 24; final float scaleWidthPercent = ((float) scaleWidth) / overlayImage.getIntrinsicWidth(); final float scaleHeightPercent = ((float) scaleHeight) / overlayImage.getIntrinsicHeight(); ScaleDrawable scaleDrawable = new ScaleDrawable(overlayImage, 0, scaleWidthPercent, scaleHeightPercent); Drawable scaledOverlay = scaleDrawable.getDrawable(); scaledOverlay.setBounds(0, 0, width, height); scaledOverlay.draw(imageCanvas); // Combine background and text to a LayerDrawable LayerDrawable layerDrawable = new LayerDrawable( new Drawable[] { backgroundImage, new BitmapDrawable(canvasBitmap) }); Bitmap newBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); layerDrawable.setBounds(0, 0, width, height); layerDrawable.draw(new Canvas(newBitmap)); return newBitmap; }