I want to get background color of a view in hex format.
for example consider
int getViewBackgroundColor(View view) my excepted return vaule is
How could I do this?
LinearLayout layout = (LinearLayout) findViewById(R.id.lay1); ColorDrawable viewColor = (ColorDrawable) layout.getBackground(); int colorId = viewColor.getColor();
After getting as integer type of color, now you have to convert to hexadecimal:
String hexColor = String.format("#%06X", (0xFFFFFF & colorId));
Hope this helps..
Answered By – Nikhil Borad
Answer Checked By – Cary Denson (FlutterFixes Admin)