当我使用dialog.builder时,字体大小是正确的,但当我使用MaterialAlertDialogBuilder时,正文文本的字体较小。还好吗?
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()

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

问题出在哪里?
发布于 2019-09-26 06:01:33
这是故意的。他们使用不同的风格。
您可以使用类似以下内容来更改它:
<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();


发布于 2019-05-17 10:00:51
你可以像这样解决:
<item name="materialAlertDialogTheme">@style/ThemeOverlay.MyApp.Dialog</item>
<style name="ThemeOverlay.MyApp.Dialog" parent="@style/ThemeOverlay.MaterialComponents.Dialog">
<item name="android:dialogCornerRadius" tools:targetApi="p">@dimen/dp_4</item>
<item name="android:paddingBottom">@dimen/dp_2</item>
...
</style>发布于 2019-07-18 02:29:13
您需要使用MaterialAlertDialogBuilder而不是AlertDialog.Builder。
MaterialAlertDialogBuilder(this)
.setMessage("This is a test of AlertDialog.Builder")
.setPositiveButton("Ok", null)
.show()https://stackoverflow.com/questions/56098162
复制相似问题