我想在狀態欄後面設置AlertDialog位置,當我的對話框中的內容增加時,該怎麼做?我創建一個自定義AlertDialog用我自己的佈局....請幫我....如何在Android中將AlertDialog的位置設置爲頂部的屏幕?
下面是我的代碼,我設置的高度和alertDialog的xy位置,但仍亙古不變的節目其效果..
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inf = getLayoutInflater();
View layout = inf.inflate(R.layout.main, null);
builder.setView(layout);
builder.setTitle("Add to Home screen");
AlertDialog dialog = builder.create();
WindowManager.LayoutParams WMLP = dialog.getWindow().getAttributes();
int dialogOriginalHeight = WMLP.height;
WMLP.height += 750;
Log.i("XnY", "x="+WMLP.x+", y="+WMLP.y);
WMLP.x = -10; //x position
WMLP.y = -10; //y position
Log.i("XnY", "x="+WMLP.x+", y="+WMLP.y);
dialog.getWindow().setAttributes(WMLP);
Log.i("POSITION", "POS::HEIGHT:"+WMLP.height);
dialog.show();
我覺得你有做.setView()..你能告訴你的代碼呢? – 2010-07-01 23:43:45
下面是我的代碼,我設置了alertDialog的高度和x-y位置,但仍然沒有顯示它的效果.... – KISH 2010-07-02 07:32:57
AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater inf = getLayoutInflater(); View layout = inf.inflate(R.layout.main,null); builder.setView(layout); \t AlertDialog dialog = builder.create(); WindowManager.LayoutParams WMLP = dialog.getWindow()。getAttributes(); WMLP.height + = 750; (「XnY」,「x =」+ WMLP.x +「,y =」+ WMLP.y); \t WMLP.x = -10; \t // x位置 \t WMLP.y = -10; \t // y位置 \t Log.i(「XnY」,「x =」+ WMLP.x +「,y =」+ WMLP.y); \t dialog.getWindow()。setAttributes(WMLP); \t Log.i(「POSITION」,「POS :: HEIGHT:」+ WMLP.height); dialog.show(); – KISH 2010-07-02 07:34:38