I need to change radius of all four corners of a layout using SeekBar. How can I do that?
I know I can create a layout with round corners using XML, but I need to do it at runtime using SeekBar.
I need to change radius of all four corners of a layout using SeekBar. How can I do that?
I know I can create a layout with round corners using XML, but I need to do it at runtime using SeekBar.
GradientDrawable shapeDrawable = new GradientDrawable();
shapeDrawable.setShape(GradientDrawable.RECTANGLE);
shapeDrawable.setCornerRadius(100f);
shapeDrawable.setColor(Color.BLACK);
shapeDrawable.setBounds(0,0,600,600);
svMain.setBackgroundDrawable(shapeDrawable);
You can set radius for Drawables but for layouts or Views directly. The only exception (for I know) is CardViews, which have radius as an attribute.
If it is a CardView, you can easily change its radius dynamically.
wrap your layout inside a cardview and change its radius
using
app:cardCornerRadius="10dp"
simple trick....