Android examples for Graphics:Drawable Size
get Drawable Size
//package com.java2s; import android.annotation.SuppressLint; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Build; public class Main { @SuppressLint("NewApi") public static int getDrawableSize(Drawable drawable) { if (drawable == null) { return 0; }//from w ww . ja v a2s .c om Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { return bitmap.getByteCount(); } else { return bitmap.getRowBytes() * bitmap.getHeight(); } } }