set Intrinsic Bounds from Drawable - Android Graphics

Android examples for Graphics:Drawable Operation

Description

set Intrinsic Bounds from Drawable

Demo Code


//package com.java2s;

import android.graphics.drawable.Drawable;

import android.support.annotation.Nullable;

public class Main {
    public static void setIntrinsicBounds(@Nullable Drawable drawable) {
        if (drawable == null) {
            return;
        }//from  w w  w.jav  a 2  s .  co  m

        int height = drawable.getIntrinsicHeight();
        int width = drawable.getIntrinsicWidth();
        drawable.setBounds(0, 0, width, height);

    }
}

Related Tutorials