문제

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