getBackgroundColor

Returns the color if it can be retrieved from the view's background drawable, or null otherwise.

In particular:

  • If the view's background drawable is a ColorDrawable, the method will return the drawable's color.
  • If the view's background drawable is a ColorStateListDrawable, the method will return the default color of the drawable's ColorStateList.