How to make android activity show as dialog

14/04/2017   06:45:37 PM

Hello in this android article i explain how to make android activity show as dialog.It is very simple to create  android activity as dialog. 

So let's start the tutorial.

1. Create a new project in android studio/add following code to manifest file app/manifests/AndroidMainfest.xml
 
android:theme="@style/Theme.AppCompat.Dialog" 

 

add the following line of code if you use extends Activity class in MainActivity 

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

 

Android Manifest.xml file will look as  below

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xperiaitinnovations.activityasdialog">
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity"
           android:theme="@style/Theme.AppCompat.Dialog" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

 

 2. Run the application,no code needed for MainActivity.java 


Output

                   

Support us by Sharing