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