Android对话框,删除薄灰色边框(〜2px)sorrounding对话框

问题描述:

我需要一种方法来删除Android添加到对话框的视图内容的2px灰色边框。我已经尝试了本网站上标记为“确定”的大部分解决方案。期望的最终结果就是最后的图像中呈现的(一个对话框显示只是我的看法,而不由Android添加任何额外的UI元素)Android对话框,删除薄灰色边框(〜2px)sorrounding对话框

这是当前的代码:

AlertDialog.Builder builder = new Builder(this); 
builder.setView(dialogContent); //a view inflated from xml 
... 
chooseActionDialog = builder.create(); 
... 
chooseActionDialog.setView(dialogContent, 0, 0, 0, 0); //this removed the padding between grey border & actual content.. this is why i set view twice 
chooseActionDialog.show(); 
... 
Drawable d = new ColorDrawable(Color.TRANSPARENT);  
chooseActionDialog.getWindow().setBackgroundDrawable(d); //this seems to change color of padding area (between grey border & actual content) 

注:建造构造器与2个PARAMS (上下文的ThemeID)如预期doenst工作(仍然有边界&对话框被streched丑)

enter image description here

+1

当我的用户,我讨厌当开发商坚持把玩的GUI,试图让他们“KEWL”。他们通常会失败,[KISS](http://en.wikipedia.org/wiki/KISS_principle)! – 2013-03-20 07:55:33

+0

kewl,但我不是用户,只是可怜的奴隶开发者.. – pulancheck1988 2013-03-20 08:37:50

中值的style.xml创建UR自己的风格文件夹,如下图所示

<style name="Theme.Trans" parent="android:Theme.Translucent"> 
    <item name="android:windowFrame">@null</item> 
    <item name="android:windowBackground">@android:color/transparent</item> 
    <item name="android:windowIsFloating">true</item> 
    <item name="android:windowContentOverlay">@null</item> 
    <item name="android:windowTitleStyle">@null</item> 
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item> 
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item> 
    <item name="android:backgroundDimEnabled">false</item> 
    <item name="android:background">@android:color/transparent</item> 
</style> 

应用这种风格到您的对话框

final Dialog dialog = new Dialog(UrActivity.this, R.style.Theme_Trans); 
+2

我测试了与构建器构造(构建器(上下文,主题Id))相同的想法,但结果并不令人满意。使用你的代码示例,对话框完全透明..所以谢谢 – pulancheck1988 2013-03-20 08:29:23