15

Android is killing me.

I want set rounded corners for Relative layout, it's simple

Drawable XML may look like

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
 <padding android:left="1dp" android:top="1dp"
            android:right="2dp" android:bottom="2dp" />
    <solid android:color="#FFFFFF" />

    <corners android:radius="15dp" />

    <stroke
        android:width="2dp"
        android:color="#FFF" />

</shape>

But, if I insert into Relative layout other layout or else widget like ImageView I got not clipped childs - see picture

enter image description here

How you can see I got not clipped child element.

How do I do this right?

Maybe it helps I want rounded corners works like in iOS

givenView.layer.cornerRadius =roundAngle;
    [givenView.layer setBorderColor:[[borderColor colorWithAlphaComponent:alphaBorder] CGColor]];
    [givenView.layer setBorderWidth:borderWidth];
    givenView.clipsToBounds = YES;

Also I want show every one who think that padding it's solution:

enter image description here

Here set padding.

For correctly understating problem look at hierarchy picture

enter image description here

In here:

RelativeLayout - have described xml as background,

LinearLayout - container for custom objects with complex layouts which contains image as background and else widgets

profileStatistic - complex custom widget with many sub-objects in outer layout.

FULL picture of layout is:

enter image description here

And layout for inside controls (profileStatistic):

enter image description here

P.S. I do not need 9-path. Question not about 9-path!

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Dmitry Nelepov
  • 7,246
  • 8
  • 53
  • 74

1 Answers1

1

if you see the image rounded corner is getting applied. but child of the layout is not having round rect. that's why that corner of the is going out of the background of the parent. to solve this either you give some padding to the parent layout so that it will not go out of the parent layout's background. Or you can apply same kind of rounded corner shape drawable to the child view also.

Raj
  • 1,843
  • 2
  • 21
  • 47
  • It's not correct. Bacuse here situation: if rounded corners set to 15dp, and padding (to correcting) set to 5dp, i get space place between frame border and inside content widget. – Dmitry Nelepov Oct 11 '12 at 11:55
  • that given 5dp padding is not sufficient for the 15dp radius. that's why those cornets are going out. you can increase that padding and check. – Raj Oct 11 '12 at 12:02