1. 程式人生 > >android dialog去掉標題欄和邊框

android dialog去掉標題欄和邊框

首先在 values/Style.xml檔案中加入以下程式碼(如果沒有該檔案就建立一個XML名為Style.xml)

<!--重寫系統彈出Dialog -->
    <style name="myDialogTheme" parent="android: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><!--除去title-->
        <item name="android:windowContentOverlay">@null</item> 
        <item name="android:backgroundDimEnabled">false</item>
        <item name="android:windowBackground">@null</item><!--除去背景色-->
    </style> 

去掉背景色邊框也就去掉了,在你的層中設定背景色就可以了  

第二步在AndroidManifest.xml中在你註冊activity中加入android:theme="@style/myDialogTheme" 這個名就是上面的樣式名稱

<activity android:name=".LoginDialog" android:theme="@style/myDialogTheme" android:screenOrientation="portrait"/>

彈出層方法

 Intent intent=new Intent(Detail_Goods.this,LoginDialog.class);
startActivity(intent);