Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FrameLayout with rounded corners

I have a FrameLayout inside my root view (linear:vertical) that I'm using to hold different fragments depending on user input. The FrameLayout is smaller than the background, so it appears to be "floating".

How do I round the corners of the FrameLayout?

The frags that go inside the FrameLayout are not pictures, so I can't crop them.

like image 987
Dan Lehto Avatar asked Mar 24 '16 19:03

Dan Lehto


1 Answers

Create an xml file, e.g. your_rounded_shape.xml, in your drawable folder and add the following code:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#CCCCCC"/>    

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

    <padding android:left="2dp"
         android:top="2dp"
         android:right="2dp"
         android:bottom="2dp"/> 

    <corners android:radius="8dp" />
</shape>

Then use your_rounded_shape.xml as a background in your FrameLayout. Something like this:

<FrameLayout
    android:width="match_parent"
    android:height="wrap_content"
    android:background="@drawable/your_rounded_shape"/>
like image 59
Masum Avatar answered Sep 21 '22 19:09

Masum