SoFunction
Updated on 2025-04-07

Implementation code for popping up Dialog animation effect from the lower left corner of the screen in Android

MainActivity Code:

import ;
import ;
import .;
import ;
import ;
import ;
import ;
import ;
public class MainActivity extends AppCompatActivity {
private View inflate;
private Dialog dialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
 (savedInstanceState);
 setContentView(.activity_main);
}
public void click(View view) {
 dialog = new Dialog(this,);
 //Fill the layout of the dialog box inflate = (this).inflate(.item_dialog, null);
 //Initialize the control //Set the layout to Dialog (inflate);
 //Get the form where the current activity is located Window dialogWindow = ();
 //Set Dialog pops up from the bottom of the form ( );
 //Get the form's properties  lp = ();
  = 20;//Set the distance from the bottom of the Dialog  = .MATCH_PARENT;
// Set properties to form (lp);
 ();//Show dialog box }
}

Layout of the main interface:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:andro
xmlns:tools="/tools"
android:
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="">
<TextView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Hello World!"
 android:onClick="click"/>
</LinearLayout>

Dialog layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:andro
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:src="@drawable/hani_gift_1"
 android:layout_gravity="center"/>
</LinearLayout>

Styles code:

 <style name="ActionDialogStyle" parent="@android:style/">
   
&lt;!-- Transparent background --&gt;
 &lt;item name="android:windowBackground"&gt;@android:color/transparent&lt;/item&gt;
 &lt;item name="android:windowContentOverlay"&gt;@null&lt;/item&gt;
 &lt;!-- Floating onActivityAbove --&gt;
 &lt;item name="android:windowIsFloating"&gt;true&lt;/item&gt;
 &lt;!-- frame --&gt;
 &lt;item name="android:windowFrame"&gt;@null&lt;/item&gt;
 &lt;!-- DialogBlur effect outside the area --&gt;
 &lt;item name="android:backgroundDimEnabled"&gt;true&lt;/item&gt;
 &lt;!-- Untitled --&gt;
 &lt;item name="android:windowNoTitle"&gt;true&lt;/item&gt;
 &lt;!-- translucent --&gt;
 &lt;item name="android:windowIsTranslucent"&gt;true&lt;/item&gt;
 &lt;!-- DialogEnter and exit animation --&gt;
 &lt;item name="android:windowAnimationStyle"&gt;@style/ActionSheetDialogAnimation&lt;/item&gt;
&lt;/style&gt;
&lt;!-- ActionSheetEnter and exit animation --&gt;
&lt;style name="ActionSheetDialogAnimation" parent="@android:style/"&gt;
 &lt;item name="android:windowEnterAnimation"&gt;@anim/actionsheet_dialog_in&lt;/item&gt;
 &lt;item name="android:windowExitAnimation"&gt;@anim/actionsheet_dialog_out&lt;/item&gt;
&lt;/style&gt;

Enter the animation (start to zoom in at the bottom left corner):

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:andro
android:duration="1000"
android:fromXScale="0"
android:toXScale="100%"
android:fromYScale="0"
android:toYScale="100%"
android:pivotX="0%"
android:pivotY="100%"
/>

Exit animation (move down):

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:andro
android:duration="200"
android:fromYDelta="0"
android:toYDelta="100%" />

The above is the implementation code for the Dialog animation effect popping up from the lower left corner of the screen in Android introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!