Srujan Simha Srujan Simha - 1 year ago 125
Android Question

Get background color of a Layout

I want to find the background color of a Layout from my code. Is there any way to find it? something like


Answer Source

This can only be accomplished in API 11+ if your background is a solid color.

            int color = Color.TRANSPARENT;
            Drawable background = view.getBackground();
            if (background instanceof ColorDrawable)
                color = ((ColorDrawable) background).getColor();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download