How to make your activity appear like a dialog box in android?

By | February 5, 2012

Hello all..

Today I will talk about how to theme your activities the way you want.
Besides that android provides many built in themes that you can use instead of all writing it yourselves.
One of those kind is making the activity appear like a dialog box.

Here is how you do it.
After creating your activity -> go to AndroidManifest.xml. then add this inside the activity tag.

android:theme=”@android:style/Theme.Dialog”

After that the manifest will look something like this.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.coderzheaven.pack"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.Dialog">
        <activity android:name=".ThemeActivityDemo"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

The activity for which you have added this theme will appear as a dialog as shown in the figure.

Theme Android activity

Theme Android activity

2 thoughts on “How to make your activity appear like a dialog box in android?

  1. Pingback: How to place layouts one over another in andriod using addContentView()? | Coderz Heaven

  2. Pingback: Apply Custom Theme for your activity in android. | Coderz Heaven

Leave a Reply

Your email address will not be published. Required fields are marked *