Show Dialog almost full screen in my case (with ActionBar & overlay)

I am working with the Android Support Package .

I created a dialog:

Dialog dialog = new Dialog(activity, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);

Since I would like to show the dialog in full screen mode, so I applied a theme to it Theme_Translucent_NoTitleBar_Fullscreenand it works.

I have two questions:

  • I would like my dialog to appear as a full screen, but leave the top ActionBar not covered by it, what topic should I use then?

  • How to have a gray overlay to also display the view covered by the dialog box (suppose my first qustion is enabled)?

+5
source share
1 answer
  • , , .
  • . , .

, (1):

public class MyDialog extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // ... your code
}

public void show(FragmentManager fragmentManager) {
    FragmentTransaction ft = fragmentManager.beginTransaction();
    String tag = MyDialog.class.getName();
    ft.add(android.R.id.content, this, tag);
    ft.commit();
}

private void dismiss() {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.remove(this);
    ft.commit();
}
}
+2

All Articles