how to get rounded dialog theme for activity

android

Solution

You could make your own `theme` that has rounded corners. First you'll need a `drawable` for the `Activity` background:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

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

    <solid android:color="#565656" />

    <stroke
        android:width="3dp"
        android:color="#ffffff" />

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

</shape>

Next make your own theme that extends the parent `Theme.Dialog`:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="ThemeWithCorners" parent="android:Theme.Dialog">
        <item name="android:windowBackground">@drawable/another_test_drawable</item>
    </style>


</resources>

This will be in a file named `styles.xml` in the `res/values` folder. Use this theme in the android manifest for the `Activity` you want:

//...
<activity
            android:name=".ActivityName"
            android:label="@string/app_name"
            android:theme="@style/ThemeWithCorners" >
//...

Problem

I need to create a activity which should look like as a dialog box with a rounded corners. For this requirement I set ``` android:theme="@android:style/Theme.Dialog" ``` Now my activity looks like a dialog box but I need its corners to be rounded. Then I created xml with attribute and set this drawable as my activity theme but now my activity not looks like dialog box. Please suggest me what can be done so that my activity looks like dialog box with rounded corners.

Original source