Reputation: 4470
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
How to solve this problem ?
thanks in advance
Upvotes: 1
Views: 2115
Reputation:
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);
Upvotes: 2
Reputation: 1283
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?
Upvotes: 1