The CardView widget has a setElevation(4f)
parameter that runs on the API >= 21
. For API < 21
there is a cardView.setCardElevation(4f)
, but it does not work.
CardView cardView = new CardView(getActivity()); if (Build.VERSION.SDK_INT >= 21) { cardView.setElevation(4f); } else { cardView.setCardElevation(40f); }
I don’t call or still need to create a new View with my hands, paint it in a gradient, and then cardView.addView(myGradienShadow);
like a shadow?
cardView
in a loop and fill it there. In the markup onlyLinearLayout
, in which everything is then added viaaddView
. I did it earlier through LinearLayout, to which I added a View with a gradient of the fill color LinearLayout. But the shadow was not very likely and plausible. I decided tocardView
into thecardView
theme, and here is the problem with elevation. - web_alex