gpt4 book ai didi

android - MaterialAlertDialogBu​​ilder 怎么用才好?

转载 作者:行者123 更新时间:2023-11-29 02:20:34 26 4
gpt4 key购买 nike

当我使用 dialog.builder 时,字体大小是正确的,但是当我使用 MaterialAlertDialogBu​​ilder 时,正文的字体大小较小。可以吗?

implementation 'com.google.android.material:material:1.1.0-alpha06'

我用的是这个主题

<style name="AppTheme" parent="Theme.MaterialComponents.Light">

MaterialComponent代码

MaterialAlertDialogBuilder(this)
.setMessage("This is a test of MaterialAlertDialogBuilder")
.setPositiveButton("Ok", null)
.show()

Screenshot_20190512-115103_2

AlertDialog.Builder

AlertDialog.Builder(this)
.setMessage("This is a test of AlertDialog.Builder")
.setPositiveButton("Ok", null)
.show()

Screenshot_20190512-115241_2

问题出在哪里?

最佳答案

这是故意的。他们使用不同的风格。

您可以使用类似的方式更改它:

  <style name="Body_ThemeOverlay.MaterialComponents.MaterialAlertDialog" parent="@style/ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="materialAlertDialogBodyTextStyle">@style/BodyMaterialAlertDialog.MaterialComponents.Body.Text</item>
</style>
<style name="BodyMaterialAlertDialog.MaterialComponents.Body.Text" parent="MaterialAlertDialog.MaterialComponents.Body.Text">
<item name="android:textColor">@color/colorAccent</item>
<item name="android:textAllCaps">true</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">bold</item>
</style>

然后:

 new MaterialAlertDialogBuilder(this,
R.style.Body_ThemeOverlay_MaterialComponents_MaterialAlertDialog)
.setTitle("Title")
.setMessage("Message......")
...
.show();

enter image description here enter image description here

关于android - MaterialAlertDialogBu​​ilder 怎么用才好?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56098162/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com