Android 圆角dialog
2021-01-11 本文已影响0人
ryanxun
public class RoundCornerDialog extends Dialog {
private static int default_width = 160; //默认宽度
private static int default_height = 120;//默认高度
public RoundCornerDialog(Context context, View layout, int style) {
this(context, default_width, default_height, layout, style);
}
public RoundCornerDialog(Context context, int width, int height, View layout, int style) {
super(context, style);
setContentView(layout);
Window window = getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.gravity = Gravity.CENTER;
window.setAttributes(params);
}
//圆角的dialog样式,在values——》styles中设置
// <style name="RoundCornerDialog" parent="@android:style/Theme.Dialog">
// <item name="android:windowFrame">@null</item>
// <item name="android:windowIsFloating">true</item>
// <item name="android:windowIsTranslucent">true</item>
// <item name="android:windowNoTitle">true</item>
// <item name="android:background">@android:color/transparent</item>
// <item name="android:windowBackground">@android:color/transparent</item>
// <item name="android:backgroundDimEnabled">true</item>
// <item name="android:backgroundDimAmount">0.6</item>
// </style>
}