How to create Dialog Box in Android Using Activity - SpartaCode


Make your development faster and easier !

How to create Dialog Box in Android Using Activity

Why ?

I have found creating activity is very easy than creating a custom dialog box or alert box if you agree with this +1 the post ❤.

Even managing event in activity is very easy so i decided to use activity as an custom dialog box.
You can find such example in my app :

Lets get Started.

To make beautiful dialog box as above you need to use CardView.

Setup CardView

Step 1: Create new Activity 

Right click on app package -> New -> Activity ->Empty Activity

Step 2: Go to style.xml file in resource package->values  and paste this code 

<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">

        <item name="android:windowIsTranslucent">true</item>

        <item name="android:statusBarColor">@android:color/transparent</item>

        <item name="android:windowBackground">@android:color/transparent</item>


Step 3: Make some changes in AndroidManifest.xml

<activity android:name=".YourActivityName"



Now, Run project and see output.

Note : Your activity will be completely transparent thats why you wont see anything after you open activity.
To see something in activity just add your design into this activity and make it beautiful.

Thank you 
please like and subscribe

No comments:

Post a Comment