1,在res/styles中自定义dialog的风格
<style name="vipKbDialogStyle" parent="@android:style/Theme.Dialog">
<!-- 边框 -->
<item name="android:windowFrame">@null</item>
<!-- 是否浮现在activity之上 -->
<!-- -->
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item> <!-- 半透明 -->
<!-- 无标题 -->
<item name="android:windowNoTitle">true</item>
<!-- 覆盖背景图片 -->
<item name="android:windowBackground">@android:color/transparent</item>
<!-- 设置自定义布局的背景透明 -->
<item name="android:background">#000000</item>
<item name="android:backgroundDimEnabled">false</item> <!-- 模糊 -->
</style>
2,构造器中引用风格
public VipKeyboardDialog(Context context) {
// super(context, R.style.Theme_Transparent);
super(context, R.style.vipKbDialogStyle);
//指定布局
setContentView(R.layout.dialog_vip_keyboard);
setCancelable(true);
3,设置弹框显示位置
vipKeyboardDialog = new VipKeyboardDialog(getActivity());
//设置弹框位置坐标
Window dialogWindow = vipKeyboardDialog.getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
lp.x = 200;
lp.y = 10;
dialogWindow.setAttributes(lp);