-1

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.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Sadeel Anjum
  • 135
  • 2
  • 14

3 Answers3

1
        GradientDrawable shapeDrawable = new GradientDrawable();
    shapeDrawable.setShape(GradientDrawable.RECTANGLE);
    shapeDrawable.setCornerRadius(100f);
    shapeDrawable.setColor(Color.BLACK);
    shapeDrawable.setBounds(0,0,600,600);
    svMain.setBackgroundDrawable(shapeDrawable);
tiny sunlight
  • 6,231
  • 3
  • 21
  • 42
0

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.

hata
  • 11,633
  • 6
  • 46
  • 69
0

wrap your layout inside a cardview and change its radius using

app:cardCornerRadius="10dp" 

simple trick....

Mangaldeep Pannu
  • 3,738
  • 2
  • 26
  • 45