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);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM