Faisal Ahsan Faisal Ahsan - 5 months ago 72
Android Question

How to change card_view:cardCornerRadius programmatically

In my project, I am using

RecyclerView
in my listing using
CardView
. In my listing I have to set the corner radius of
CardView
dynamically based on device.

Is there any way to set cardview corner radius value dynamically?

Thanks.

Answer

Use CardView.setRadius(float), see here.

The documentation is pretty good for finding xml attrs and their equivalent methods, it really takes a few seconds.