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..
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)
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 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>
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...
I've spent literally 3-4 hours on this, i hope someone else can help out...
Try this if you like to:
For completely transparent use: setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
For custom background -create a style file in you values folder (values/style.xml) and use it: setStyle(DialogFragment.STYLE_NO_FRAME, yourpackagename.R.style.YOURE_CUSTOM_STYLE);
in your style file override the atribute: android:windowBackground to be @color/DialogBackgroundBlackSemiTransparent
You can achieve by adding this in Dialog Fragment or BottomSheetDialogFragment
In
onCreateDialog
MethodSet your theme like this worked for me
And in your dialog fragment set like this
In
onActivityCreated
for
DialogFragment
transparent