Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird black line above DialogFragment AlertDialog

I have a screenshot below of a random dark/black slightly downwards gradient line appearing above my dialog fragments.

These are build with a dialogfragment class that has been overridden, and an alertdialog builder is being used to construct them (happens with and without the title/buttons) inside the following method

public Dialog onCreateDialog(Bundle savedInstanceState)

Anyone had this happen to them before or have any ideas?

Ive tried to theme them differently, and the same happens with both API14 holo and holoeverywhere library. Ive tried to set the backgrounds to transparent ect... but havent achieved anything except making the dim go away.

Dark lin

like image 736
Glenn.nz Avatar asked Jan 13 '23 06:01

Glenn.nz


2 Answers

You need to add your custom theme for your dialog and provide android:windowContentOverlay parameter.

<style name="MyDialogTheme">
    <item name="android:windowContentOverlay">@null</item>
</style>

Then, in your DialogFragment in onCreate call:

setStyle(/* desired style */, R.style.MyDialogTheme);
like image 63
Dmitry Zaytsev Avatar answered Jan 24 '23 00:01

Dmitry Zaytsev


The Weird Line appears because of the title bar. You just need to hide the title bar and it automatically hides the weird line:

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);

    // request a window without the title
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    // make your dialog here
    return dialog;
}
like image 24
Shahab Rauf Avatar answered Jan 23 '23 23:01

Shahab Rauf