Simple solution: Use a FrameLayout and set the foreground drawable: https://developer.android.com/reference/android/widget/FrameLayout.html#setForeground(android.graphics.drawable.Drawable) The foreground drawable is drawn *over/on top of* the background and the children of a FrameLayout. If the foreground drawable is transparent in the middle and has the background color at the corners (outside the rounded corners), you may get the effect you want.
More tricky solution: Subclass the RelativeLayout into a class of your own and override the dispatchDraw method. Before calling super.dispatchDraw(canvas), set a clip path/region on the canvas (restore the canvas to its original state after the call to dispatchDraw). This will clip the drawing of its children. This clip path/region can define the rounded corners you want. On Wednesday, November 12, 2014 5:54:02 PM UTC-5, dashman wrote: > > I've got a view that goes into a listview and would like each to have a > rounded corners. > > For the custom view layout, I set the parent to a RelativeLayout and > and set the background to a shape - that sets rounded corners. > > <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:background="@drawable/bg" > > > > But the problem is that if inside the view, if i draw to the edges - it > doesn't > get clipped to the rounded corners. > > Any way to force that. > > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

