【问题标题】:How to change text size of a checkbox list within an alert dialog如何在警报对话框中更改复选框列表的文本大小
【发布时间】:2014-05-28 00:00:08
【问题描述】:

我正在处理一个包含多个复选框的警报对话框。如何更改复选框列表元素的文本大小? (我可以改变标题和按钮的大小就好了)

boolean[] allBoolean = {true, true, true, true, true, true, true, true};

AlertDialog.Builder prompt = new AlertDialog.Builder(Class.this);
prompt.setTitle("Title");
prompt.setMultiChoiceItems(all, allBoolean, new DialogInterface.OnMultiChoiceClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which, boolean isChecked) {
        allBoolean[which] = isChecked;
    }
});
prompt.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) { 
        //do nothing
    }
});
prompt.setPositiveButton("Select", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) { 
        //do something
    }
});

【问题讨论】:

  • 你应该去自定义对话框

标签: java android checkbox android-alertdialog


【解决方案1】:
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);

【讨论】:

  • 抱歉,如果我遗漏了什么。您的代码将如何更改文本大小?
  • 查看另一个答案希望对您有所帮助!
【解决方案2】:

您实际上可以很容易地访问消息的 TextView,然后更改它的大小。我用更大的尺寸进行了测试,但你可以使用任何你想要的尺寸。文本将像它已经滚动一样很好地滚动。视图的 id 是 android.R.id.message :

AlertDialog dialog = new AlertDialog.Builder(this).setMessage("Hello world").show();
TextView textView = (TextView) dialog.findViewById(android.R.id.message);
textView.setTextSize(40);

这可能是一个更清洁的解决方案,但我不确定 TextView 是否存在可能为空的风险。

【讨论】:

  • 这只会改变消息的文本大小。它不会改变多选元素的文本大小。
猜你喜欢
  • 2013-09-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-13
  • 1970-01-01
  • 2017-09-14
相关资源
最近更新 更多