Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The following Mono for Android C# code does the trick (but should be easy to port to Java). I tested on Android 2.2 (Galaxy S) and Android 4.1 (Nexus 7). The only thing you would need to change are the layout IDs used for the parent view and dialog view.</p> <pre><code>[Activity (MainLauncher = true)] public class TestCustomDialogActivity : FragmentActivity { public class MyDialogFragment : Android.Support.V4.App.DialogFragment { public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Android 3.x+ still wants to show title: disable Dialog.Window.RequestFeature(WindowFeatures.NoTitle); // CHANGE TO YOUR DIALOG LAYOUT or VIEW CREATION CODE return inflater.Inflate(Resource.Layout.MyLayout, container, true); } public override void OnResume() { // Auto size the dialog based on it's contents Dialog.Window.SetLayout(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); // Make sure there is no background behind our view Dialog.Window.SetBackgroundDrawable(new ColorDrawable(Color.Transparent)); // Disable standard dialog styling/frame/theme: our custom view should create full UI SetStyle(Android.Support.V4.App.DialogFragment.StyleNoFrame, Android.Resource.Style.Theme); base.OnResume(); } } protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // CHANGE TO YOUR MAIN SCREEN SetContentView(Resource.Layout.MyDialog); var dialog = new MyDialogFragment(); dialog.Show(SupportFragmentManager, "dialog"); } } </code></pre> <p>I uploaded a full Mono for Android sample to <a href="https://github.com/t9mike/CustomDialogFragmentSample" rel="noreferrer">https://github.com/t9mike/CustomDialogFragmentSample</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload