如何从对话框删除边框? [英] How to remove border from Dialog?

查看:153
本文介绍了如何从对话框删除边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这显示在对话框的活动:

I have an activity which is shown in a dialog:

为了去除边框和圆角,我想这样的:

In order to remove border and rounded corners, i tried this:

<resources>
  <style name="ActivityDialog" parent="@android:style/Theme.Dialog">
  <item name="android:windowBackground">@null</item> 
    <item name="android:windowFrame">@null</item>
</style>

边框消失了,但遗憾的是也该对话框周围的空白。

The border is gone, but sadly also the margin around the dialog.

推荐答案

边框,圆润的边角和利润都是由定义的android:windowBackground 。 (参数安卓窗框已被设置为 @null Theme.Dialog 的风格,因此将其设置为 @null 再没有任何影响。)

The border, round corners and margin are all defined by android:windowBackground. (Parameter android:windowFrame is already set to @null in Theme.Dialog style, therefore setting it to @null again has no effect.)

为了去除你必须到Android修改边框和圆角:windowBackground 适当。该 Theme.Dialog 的风格将其设置为 @android:绘制/ panel_background 。这是一个9补丁绘制看起来像这样(这个人是华电国际版):

In order to remove the border and round corners you have to change the android:windowBackground appropriately. The Theme.Dialog style sets it to @android:drawable/panel_background. Which is a 9-patch drawable that looks like this (this one is the hdpi version):

正如你所看到的9补丁PNG定义的空白,边框和对话主题圆角。要删除边框和圆角,你必须创建一个合适的绘制。如果你想保持阴影渐变,你必须创建一套新的9补丁可绘(一个可绘制的每个DPI)。如果你不需要的阴影渐变,你可以创建一个形状绘制

As you can see the 9-patch png defines the margin, border and round corners of the dialog theme. To remove the border and round corners you have to create an appropriate drawable. If you want to keep the shadow gradient you have to create set of new 9-patch drawables (one drawable for each dpi). If you don't need the shadow gradient you can create a shape drawable.

所需要的风格是那么:

<style name="ActivityDialog" parent="@android:style/Theme.Dialog">      
   <item name="android:windowBackground">@drawable/my_custom_dialog_background</item>            
</style>

这篇关于如何从对话框删除边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆