2015-11-06 50 views
0

Google的对话框设计规范显示了单选对话框中的单选按钮位于文本左侧的示例dialog-specs有没有人知道如何在这些示例中定位单选按钮? 当从22.2.1使用程序兼容性AlertDialog和下面的代码,我总是让他们位于右端AppCompat AlertDialog单选按钮重力/定位

new AlertDialog.Builder(this) 
.setTitle("Choose category") 
.setSingleChoiceItems(new String[] {"One", "Two", "Three"}, -1, 
new DialogInterface.OnClickListener() { 
    @Override 
    public void onClick(DialogInterface dialog, int whichButton) { 

    } 
}) 
.setPositiveButton("OK", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int whichButton) { 

    } 
}) 
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int whichButton) { 

    } 
}).show(); 

回答

0

我强烈建议你使用这个库:

https://github.com/afollestad/material-dialogs

你可以在这里点击各种对话框:EditText,单选,用两个或三个动作按钮等。

我希望这会帮助你!

+0

感谢您的建议! 但是为了使用材质对话框,我们首先需要在api 23上进行一次调整,这在目前是不可能的,因为我们必须替换掉所有的apache http库。 –

0

使用上面的代码做了一个简单的测试项目,在API 22上,单选按钮显示为右对齐,但在API 23上,代码非常相似,它们显示为左对齐。似乎AppCompat本身的默认单选按钮对齐方式发生了变化。