Dialog dialog = new Dialog(RemindContentActivity.this, R.style.MyDialog); dialog.setContentView(R.layout.remind_dialog); Window mWindow = dialog.getWindow(); WindowManager.LayoutParams lp = mWindow.getAttributes(); lp.gravity = Gravity.BOTTOM; lp.width = LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(lp); dialog.show();
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="@null"> <Button android:id="@+id/remind_time_once" android:layout_width="match_parent" android:layout_height="50dp" android:background="#e0ffffff" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginBottom="1dp" /> <Button android:id="@+id/remind_time_repeat" android:layout_width="match_parent" android:layout_height="50dp" android:background="#e0ffffff" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" /> <Button android:id="@+id/remind_time_cancel" android:layout_width="match_parent" android:layout_height="50dp" android:background="#e0ffffff" android:layout_marginTop="20dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginBottom="20dp" /> </LinearLayout>
<style name="MyDialog" parent="@android:Theme.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowIsFloating">true</item> <item name="android:windowContentOverlay">@null</item> </style>