当我使用dialog.builder时,字体大小是正确的,但是当我使用MaterialAlertDialogBuilder时,正文文本的字体大小较小。没关系?
implementation 'com.google.android.material:material:1.1.0-alpha06'
我用这个主题
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
材料成分代码
MaterialAlertDialogBuilder(this)
.setMessage("This is a test of MaterialAlertDialogBuilder")
.setPositiveButton("Ok", null)
.show()
AlertDialog.Builder
AlertDialog.Builder(this)
.setMessage("This is a test of AlertDialog.Builder")
.setPositiveButton("Ok", null)
.show()
哪里有问题?
这是故意的。他们使用不同的风格。
您可以使用以下方法更改它:
<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();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)