开发者

Repositioning the alert dialog on Android

开发者 https://www.devze.com 2023-01-17 09:45 出处:网络
I\'m unable to resize and reposition the alert dialog box. Ple开发者_如何学JAVAase help me do this!I think not possible since the api does not support it.

I'm unable to resize and reposition the alert dialog box. Ple开发者_如何学JAVAase help me do this!


I think not possible since the api does not support it.

You should write your own class that extends the dialog or create an activity and use android:theme="@android:style/Theme.Dialog to make it look like a dialog. Then you can use standard techniques for placing widgets.


I just tried, Now, I can reposition the AlertDialog, but I can not resize it.

    Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Sample Title");
    AlertDialog d = builder.create();
    Window win = d.getWindow();
    WindowManager.LayoutParams lp = win.getAttributes();
    lp.y = 100;
    lp.width = 320; //It does not work.
    win.setAttributes(lp);
    d.show();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号