madhavi
madhavi

Reputation: 41

android remove default border for a view with rounded corners

I have a layout with 2-3 childs. Set linear layout backgroud to a following drawable using android:background property.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#373949"/>
<stroke android:width="3dip" android:color="#FFF"/>
<corners android:radius="30dip" />
<padding android:left="10dip" android:top="10dip" android:right="10dip" android:bottom="10dip" />
</shape>

But when set radius to 30dip, rounded corners getting displayed, but back to layout default gray colored border with rectangular shape is displayed. Is there any way to get rid of that ?

Thanks in advance

Upvotes: 2

Views: 4403

Answers (3)

Its not blank
Its not blank

Reputation: 3095

That rounded corner border that you see is of the parent of layout that you have changed background.If your cusytomized background belongs to your activity than the grey color you see belongs to system. You can use Hierarchy Viewer. To see it in detail. you can also refer this for your reference.

Upvotes: 0

Aashish Bhatnagar
Aashish Bhatnagar

Reputation: 2605

Try this code

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFFFF"/>
    <corners android:radius="15px"/>
    <padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" /> 
</shape>

Upvotes: 1

Adeel Pervaiz
Adeel Pervaiz

Reputation: 1356

once you change the background of the view, this drawable will no longer be active to draw UI, hence the default layout of view will be applicable, so if you want gray layout to also be rounded, make another drawable, and set that drawable instead of gray color.

Upvotes: 0

Related Questions