---
title: "Android，去除Dialog的边框"
author: "andyzhchy"
date: "2011-10-19T14:49:36Z"
tags: []
categories: ["移动开发"]
slug: "android-dialog"
draft: false
lastmod: "2011-10-30T13:46:34Z"
id: 1201733
url: "https://andyzhchy.iteye.com/blog/1201733"
---

a.首先为这个半透明弹窗新建一个名为dialog.xml的Layout
b.res/values文件夹新建名为 dialogStyle.xml的resources样式文件，具体代码如下：
       
```xml
 
    <?xml version="1.0" encoding="utf-8"?>
        <resources>
            <style name="dialog" parent="@android:style/Theme.Dialog">
                <item name="android:windowFrame">@null</item>
                <item name="android:windowIsFloating">true</item>
                <item name="android:windowIsTranslucent">false</item>
                <item name="android:windowNoTitle">true</item>
                <item name="android:windowBackground">@drawable/dia_bg</item>
                <item name="android:backgroundDimEnabled">false</item>
            </style>
        </resources>
```

c.

```java
 
        View diaView=View.inflate(this, R.layout.dialog, null);
        dialog=new Dialog(AuthorizeActivity.this,R.style.dialog);//这里应用了你的自定义样式
        dialog.setContentView(diaView);
        dialog.show();
```
   

注：本文取自于网络