Center message in android dialog box

前端 未结 8 821
野趣味
野趣味 2020-11-29 01:53

I want the message text within my dialog box to be center aligned.

8条回答
  •  春和景丽
    2020-11-29 02:08

    you can try this code

    public void Info(){
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Info Aplication");
        builder.setIcon(R.drawable.info_adp);
        builder.setMessage("Jakarta Hospital");
        builder.setCancelable(false);
        builder.setPositiveButton("Exit", null);
        AlertDialog dialog = builder.show();
        TextView messageView = (TextView)dialog.findViewByI(android.R.id.message);
        messageView.setGravity(Gravity.CENTER);
    }
    

提交回复
热议问题