質問

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

役に立ちましたか?

解決 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?

他のヒント

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);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top