Example usage for android.graphics.drawable ScaleDrawable setLevel

List of usage examples for android.graphics.drawable ScaleDrawable setLevel

Introduction

In this page you can find the example usage for android.graphics.drawable ScaleDrawable setLevel.

Prototype

public final boolean setLevel(@IntRange(from = 0, to = 10000) int level) 

Source Link

Document

Specify the level for the drawable.

Usage

From source file:com.landenlabs.all_UiDemo.frag.ImageScalesFrag.java

private void setScaledVector(ImageView imageView, int imageRes) {

    Drawable rawDrawable;/* www  .j  a v a 2 s . 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);
}