Sweet Alert Dialog 的确认按钮显示太细
confirm button of Sweet Alert Dialog is displayed too thin
我在这样的项目中使用 Sweet Alert Dialog:
SweetAlertDialog sweetAlertDialog = new SweetAlertDialog(this.getActivity(), SweetAlertDialog.WARNING_TYPE)
.setTitleText(title)
.setContentText(body);
sweetAlertDialog.show();
但是确认按钮太细了:
我尝试在显示对话框后设置按钮的最小高度并重新显示:
sweetAlertDialog.findViewById(R.id.confirm_button).setMinimumHeight(150);
sweetAlertDialog.show();
但是并没有解决问题。有办法纠正吗?
实际上这是行不通的,因为在他们使用的库中 style
:
<style name="dialog_blue_button" parent="android:Widget.Button">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">31dp</item>
<item name="android:background">@drawable/blue_button_background</item>
<item name="android:textSize">14sp</item>
<item name="android:paddingLeft">21dp</item>
<item name="android:paddingRight">21dp</item>
<item name="android:textColor">@color/button_text_color</item>
</style>
因此您可以在 styles.xml
中设置高度值并将其添加到您的项目中。这应该有效。
我在这样的项目中使用 Sweet Alert Dialog:
SweetAlertDialog sweetAlertDialog = new SweetAlertDialog(this.getActivity(), SweetAlertDialog.WARNING_TYPE)
.setTitleText(title)
.setContentText(body);
sweetAlertDialog.show();
但是确认按钮太细了:
我尝试在显示对话框后设置按钮的最小高度并重新显示:
sweetAlertDialog.findViewById(R.id.confirm_button).setMinimumHeight(150);
sweetAlertDialog.show();
但是并没有解决问题。有办法纠正吗?
实际上这是行不通的,因为在他们使用的库中 style
:
<style name="dialog_blue_button" parent="android:Widget.Button">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">31dp</item>
<item name="android:background">@drawable/blue_button_background</item>
<item name="android:textSize">14sp</item>
<item name="android:paddingLeft">21dp</item>
<item name="android:paddingRight">21dp</item>
<item name="android:textColor">@color/button_text_color</item>
</style>
因此您可以在 styles.xml
中设置高度值并将其添加到您的项目中。这应该有效。