Get the background color of a view - Extension

I am trying to get the arrangement color by using this code : -

 View view = component.getView();
 ColorDrawable viewColor = (ColorDrawable) view.getBackground();
 int color = viewColor.getColor();
 return color;

But it return 0, I don't know why, I want to get the color in a number or hex format.

Please help me if you know how to do it :grinning:

What is the colour of layout. your code is correct.

1 Like

It's purple.

1 Like