How to do it? In API level 17 I used:
int color = ((ColorDrawable) activityLayout.getBackground()).getColor();
But ColorDrawable
method getColor()
added in API level 11 and so I cannot use this method.
Sorry for my English.
Thanks
How to do it? In API level 17 I used:
int color = ((ColorDrawable) activityLayout.getBackground()).getColor();
But ColorDrawable
method getColor()
added in API level 11 and so I cannot use this method.
Sorry for my English.
Thanks
This may look stupid, but I suggest to draw the ColorDrawable
over 1 pixel dimension bitmap
and get the pixel color in the bitmap using bitmap.getPixel(0, 0);
// Sample Code
ColorDrawable colorDrawable=((ColorDrawable) activityLayout.getBackground());
Bitmap bitmap= Bitmap.createBitmap(1, 1, Config.ARGB_4444);
Canvas canvas= new Canvas(bitmap);
colorDrawable.draw(canvas);
int pix = bitmap.getPixel(0, 0);
bitmap.recycle();