android Dialog去掉标题栏 和边框

来源:互联网 发布:软件测试有哪些 编辑:程序博客网 时间:2024/05/16 00:52

 

首先在 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);

原创粉丝点击