Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show Dialog nearly full screen in my case (With ActionBar & overlay)

I am working with Android Support package.

I have created a dialog:

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

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

I have following two questions:

  1. I would like my dialog to show like full screen still but leave the top ActionBar not be covered by it, what Theme should I use then?

  2. How to have an gray color overlay to also show the view covered by the dialog (assume my 1st qustion has resolved)?

like image 567
Leem.fin Avatar asked Jul 09 '12 13:07

Leem.fin


1 Answers

  1. The only working solution I found is to implement pseudo-dialog based on fragment.
  2. This approach might cause some difficulties to do shadow. At least, I didn't do that.

Code sample how to do (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();
}
}
like image 56
Exterminator13 Avatar answered Oct 04 '22 04:10

Exterminator13