Search code examples
androidxmlimagelayoutandroid-shapedrawable

How to make layout with rounded corners..?


How can I make a layout with rounded corners? I want to apply rounded corners to my LinearLayout.


Solution

  • 1: Define layout_bg.xml in drawables:

    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="#FFFFFF"/>
        <stroke android:width="3dp" android:color="#B1BCBE" />
        <corners android:radius="10dp"/>
        <padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
    </shape>
    

    2: Add layout_bg.xml as background to your layout

    android:background="@drawable/layout_bg"