Skip to content Skip to sidebar Skip to footer

What Layoutparams Should Be Used In An Alertdialog?

I have a EditText object: EditText textbox = new EditText (this); textbox.setHint (something); I want to add this view to an AlertDialog using the builder. AlertDialog

Solution 1:

According to the source code here , alertdialog's root element is a LinearLayout, so I would suggest using LinearLayout.LayoutParams

Solution 2:

Even if you want to setView with view as a parameter you can always create your view in xml and inflate it using a layout inflator and then use it as a parameter.

example:

Viewview= getLayoutInflater().inflate(R.layout.yourlayout, null);
setView(view);

Solution 3:

It depends if you inflate a custom view or not.

  • If you do that, you should use the LayoutParams according the custom view container (Linear or relative).
  • If you don't use a custom view you can set Linear LayoutParams.

Post a Comment for "What Layoutparams Should Be Used In An Alertdialog?"