警报对话框按钮太近 [英] Alert dialog buttons are too close
问题描述
触摸警报"对话框的按钮后,我看到了这个东西(它们之间没有空格).
I see this thing with Alert dialog's buttons touching (there is no space between them).
无论使用哪种主题,都会发生这种情况.代码:
This happens regardless of the theme being used.. Code:
builder.setTitle(R.string.sign_in_title);
builder.setCancelable(false)
.setPositiveButton(R.string.sign_in, (dialog, id) -> {
//Todo
})
.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.cancel());
builder.create().show();
应用主题继承:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
我试图仅使用Alert.Dialog建立一个最小的项目设置,我看到了同样的东西.
I tried to build a minimum project setup just with Alert.Dialog and I see the same thing..
有什么想法吗?怎么解决?
Any ideas what is going on or how to fix it?
我知道可以更改Alert的主题以产生不同的结果,但这也意味着我的应用程序中没有统一的按钮(即绿色填充白色文本)
I'm aware that I can change Alert's theme to yield different results but that also implies that I won't have uniform buttons across my app (i.e. green filled with white text)
推荐答案
只需从支持的库中更改 AlertDialog 的导入类:
Just change imported class for AlertDialog from Supported Library:
import androidx.appcompat.app.AlertDialog;
代替
import android.app.AlertDialog;
谢谢.
这篇关于警报对话框按钮太近的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!