Pregunta

I used Dialog feature of android to read login information. It is working perfect, but login dialog shows different display size in different phone. How to fix same size for all devices.

image as shows below

enter image description here

enter image description here

How to solve this problem ?

thanks in advance

¿Fue útil?

Solución 2

You can do it by either by giving parameter at run time or creating custom dialog. Please check this Android:How can I set the AlertDialog width and height,and the button of the AlertDialog style?

Otros consejos

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(layout);
builder.setTitle("Title");
alertDialog = builder.create();
alertDialog.show();
alertDialog.getWindow().setLayout(600, 400); //Controlling width and height.

or

alertDialog.show();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();

lp.copyFrom(alertDialog.getWindow().getAttributes());
lp.width = 150;
lp.height = 500;
lp.x=-170;
lp.y=100;
alertDialog.getWindow().setAttributes(lp);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top