set Compound Drawable Size - Android Graphics

Android examples for Graphics:Drawable Size

Description

set Compound Drawable Size

Demo Code

/**/*  ww w .ja  v a2s  .c  o m*/
 * UmbalaApp
 *
 * Created by Hoang Anh on 8/10/15.
 * Copyright (c) 2015 Umbala. All rights reserved.
 */
//package com.java2s;

import android.graphics.drawable.Drawable;

import android.widget.Button;

public class Main {
    public static void setCompoundDrawableSize(Button compoundButton,
            int width, int height) {
        Drawable[] drawables = compoundButton.getCompoundDrawables();
        for (Drawable drawable : drawables) {
            if (drawable == null)
                continue;
            drawable.setBounds(0, 0, width, height);
        }

        compoundButton.setCompoundDrawables(drawables[0], drawables[1],
                drawables[2], drawables[3]);
    }
}

Related Tutorials