Android dialog去除边框代码

来源:互联网 发布:lg网络电视如何使用 编辑:程序博客网 时间:2024/04/29 20:02

 使用样式文件,在values 目录下新建styles.xml文件

Java代码:

  1. <resources>
  2. <style name="dialog" parent="@android:style/Theme.Dialog">
  3. <item name="android:windowFrame">@null</item>
  4. <item name="android:windowIsFloating">true</item>
  5. <item name="android:windowIsTranslucent">false</item>
  6. <item name="android:windowNoTitle">true</item>
  7. <item name="android:background">@android:color/black</item>
  8. <item name="android:windowBackground">@null</item>
  9. <item name="android:backgroundDimEnabled">false</item>
  10. </style>
  11. </resources>
复制代码


                  调用时,使用AlerDialog的接口类

Java代码:

  1. Dialog dialog =new Dialog(SetActivity.this, R.style.dialog);
  2. dialog.setContentView(R.layout.test);
  3. dialog.show();
  4. public Dialog(Context context, int theme) {
  5. mContext =new ContextThemeWrapper(context, theme ==0?com.android.internal.R.style.Theme_Dialog : theme);
  6. mWindowManager = (WindowManager)context.getSystemService("window");
  7. Window w = PolicyManager.makeNewWindow(mContext);
  8. mWindow = w;
  9. w.setCallback(this);
  10. w.setWindowManager(mWindowManager, null, null);
  11. w.setGravity(Gravity.CENTER);
  12. mUiThread = Thread.currentThread();
  13. mDismissCancelHandler =new DismissCancelHandler(this);
  14. }

原创粉丝点击