不能使自定义DialogFragment透明在片段 [英] Can't make the custom DialogFragment transparent over the Fragment

查看:258
本文介绍了不能使自定义DialogFragment透明在片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要建立在一个片段一个对话框(即占据整个屏幕)。对话框需要是将被定位在与变暗出该片段的外侧的片段的片段的浮动对话框..

I need to create a dialog over a fragment (that takes up the whole screen). The dialog needs to be a floating dialog that will be positioned over the fragment with the fragment darkened out outside of the fragment..

有关自定义对话框,我有一个LinearLayout中,有弯曲的边缘,无论我做什么,该对话框中有一个黑色接壤各方(非常小的)。我已经竭尽所能,使之透明,走(让所有的对话仅仅是线性布局 - 曲线箱梁)

For the custom Dialog, i have a linearLayout that has curved edges, no matter what i do, the dialog has a black bordering on all sides (very small). I've tried everything to make it transparent and go away (so that all of the dialog is just the linear layout - curved box)

对于DialogFragment,这是我对onCreateView

For the DialogFragment, this is what I have for onCreateView

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
    LinearLayout layout =(LinearLayout)inflater.inflate(R.layout.custom_dialog, null);
    LinearLayout item = (LinearLayout)layout.findViewById(R.id.display_item);
    populateItemData(item, inflater);
    return layout;
}

CUSTOM_DIALOG只是一个LinearLayout中,有安卓的backgroung设置为#000000

custom_dialog is just a LinearLayout that has android:backgroung set to #000000

这是我的风格自定义对话框

This is my style for the custom Dialog

<style name="CustomDialog" parent="android:style/Theme.Dialog">
    <item name="android:windowBackground">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowIsTranslucent">true</item> 
    <item name="android:alwaysDrawnWithCache">false</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

我尝试各种组合,这种风格(从我在网上看到),我不能摆脱那个恼人的黑接壤的,我可以画是白色或其他颜色,如果我设置的LinearLayout背景以外的任何#000000其它...

I tried all kinds of combinations in this style (from what I've seen online) and I can't get rid of that annoying black bordering, I can paint it white or any other color if i set that LinearLayout background to anything other than #000000...

我已经花了字面上3-4个小时在此,我希望有人能够帮助你了...

I've spent literally 3-4 hours on this, i hope someone else can help out...

推荐答案

尝试

getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0));

DialogFragment onCreateView

这篇关于不能使自定义DialogFragment透明在片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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