It turns out that calling View.setBackgroundColor(int) on the CardView removes the rounded corners.
To change the background color on the map and save the corners, you need to call CardView.setCardBackgroundColor(int) .
This may be the case for some visitors to this post.
With a subclass of CardView I suggest adding the following method to protect your corners from being accidentally deleted:
@Override public void setBackgroundColor(@ColorInt int backgroundColor) { setCardBackgroundColor(backgroundColor); }
In particular, I worked on implementing a custom view for React Native, and React automatically applied the background color to the view. This redefinition solved this problem; this means that other developers do not need to know the details of the underlying view.
source share