I'm following the technique outlined here in order to have my Dialog float to the bottom of the screen and take up the full width, similar to a drawer. This works on every version of Android that I'm targeting (16+) except for Lollipop. The Dialog will float behind the software navigation buttons (back, home and stack), making it impossible to press the negative or positive buttons on my dialogs.
I've tried the method outlined here but was unsuccessful. I've considered adding a bottom padding to all of my dialogs - but this means I'll have to set custom views instead of using the alertdialog builders other methods. I think there may be a way to avoid this that I am not finding.
EDIT 1:
I've tried the setSystemUiVisibility method now, by disabling the flags for fullscreen, immersive and hide navigation. However the dialog, when created, still sits behind the navigation buttons on the screen (tested in API 22). I've also tried
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
Here is my current code:
@Override
public void onStart()
{
super.onStart();
AlertDialog dlg = (AlertDialog) getDialog();
Window window = dlg.getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.BOTTOM;
window.setAttributes(params);
View decor = window.getDecorView();
int flagset = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
decor.setSystemUiVisibility(decor.getSystemUiVisibility() & ~flagset);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.Theme_DialogTheme);
//various methods adding elements to dialog
Dialog dlg = builder.create();
return dlg;
}
and my styles:
<style name="Theme.SnapTrash" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@android:color/black</item>
<item name="colorPrimary">@color/colorSnapTrashPrimary</item>
<item name="android:colorBackground">@color/colorSnapTrashPrimary</item>
<item name="android:textColorPrimary">@color/colorSnapTrashTextPrimary</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
<item name="colorAccent">@color/colorSnapTrashAccent</item>
<item name="colorPrimaryDark">@color/colorSnapTrashPrimaryDark</item>
<item name="android:colorForeground">@android:color/black</item>
<item name="android:textColorPrimaryInverse">@color/colorSnapTrashTextPrimaryInverse</item>
<item name="android:navigationBarColor">@android:color/black</item>
<item name="android:textColorSecondaryInverse">@color/secondary_text_material_dark</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowTranslucentNavigation">false</item>
</style>
<style name="Theme.DialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowBackground">@android:color/white</item>
<item name="android:windowIsFloating">false</item>
<item name="android:textColor">#FFEF5350</item>
<item name="android:textColorPrimary">#FFEF5350</item>
<item name="android:colorAccent">#999</item>
</style>
Is your navicationbar translucent? Is your dialog behind the navicationbar? If this,you can set the dialog's theme.For example,you can set the dialog's window flag not full screen,not translucent.If it doesn't work,you set the UI flag like this method:setSystemUiVisibility(int arg)