Android:How can I set the AlertDialog width and height,and the button of the AlertDialog style?

前端 未结 2 2078
暗喜
暗喜 2020-12-06 07:28

I have a task to change the AlertDialog width and height by xml,I want make that become style,so I can use it easy.And that ,I need to change button of AlertDialog style als

2条回答
  •  孤街浪徒
    2020-12-06 07:45

    Try this, this works for me,

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setView(layout);
    builder.setTitle("Title");
    alertDialog = builder.create();
    alertDialog.getWindow().setLayout(600, 400); //Controlling width and height.
    alertDialog.show();
    

提交回复
热议问题