Custom Dialog box With Animation

 Here is the full code for In the button_gradient.xml file in your res/drawable directory, you can define the gradient like this:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#FF3366"
android:endColor="#FF9933"
android:angle="45" />
</shape>

Background XML Design Code background.xml file in your res/drawable directory

Picture 


Open styles.xml file and add the following code.

  1. Open your project's res directory.
  2. Inside the res directory, locate the values directory.
  3. Create a new file named styles.xml inside the values directory.
  4. Open the styles.xml file.
  5. Add the following content to define the 'DialogAnimation' style:
<resources>
<style name="DialogAnimation">
<item name="android:windowEnterAnimation">@android:anim/slide_in_left</item>
<item name="android:windowExitAnimation">@android:anim/slide_out_right</item>
</style>
</resources>



Java Code :



In the code above, replace parentLayout with the actual layout where you want to add the dynamically created LinearLayout. Also, make sure to replace R.drawable.recyclerview_background_cell, R.drawable.edit_show_icon, R.drawable.button_gradient, and R.color.black with the respective resource identifiers in your project.

The dpToPx() method is a utility method to convert density-independent pixels (dp) to pixels (px). You can define this method as follows:



Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.