2014-03-13 23 views
1

我用android的對話框功能來讀取登錄信息。它工作完美,但登錄對話框在不同的手機中顯示不同的顯示尺寸。如何爲所有設備修復相同的大小。如何在android中修復對話框的尺寸

圖像顯示如下

enter image description here

enter image description here

如何解決這個問題呢?

在此先感謝

+0

u需要設置高度和寬度對話框。 – saravanan

回答

2
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. 

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); 
相關問題