Как сделать так, чтобы текст в кнопке выравнивался вправо, используя стиль в компоненте материала? - PullRequest
0 голосов
/ 15 апреля 2020

enter image description here

Я использую компонент материала, и у меня есть кнопка в диалоге предупреждений, как на изображении выше, с использованием стиля ниже

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="materialAlertDialogTheme">@style/AlertDialogMaterialTheme</item>
</style>

<style name="AlertDialogMaterialTheme" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
    <item name="buttonBarNegativeButtonStyle">@style/Alert.Button.Negative</item>
</style>

<style name="Alert.Button.Negative" parent="Widget.MaterialComponents.Button.OutlinedButton">
    <item name="strokeColor">@color/color_0054BB</item>
    <item name="android:textColor">@color/color_0054BB</item>
    <item name="android:textAllCaps">false</item>
    <item name="android:textSize">14sp</item>
    <item name="android:layout_marginEnd">8dp</item>
    <item name="rippleColor">@color/colorAccent_main</item>
</style>

Как видите, текст «Отмена» находится в центре кнопки. но теперь мне нужно сделать так, чтобы текст отмены выровнялся вправо. как сделать что-то подобное?

Я использую приведенный ниже код для того, как диалоговое окно предупреждения

MaterialAlertDialogBuilder(mContext)
     .setTitle("this is title")
     .setMessage("this is message")
     .setPositiveButton("Yes") { _, _ ->

     }
     .setNegativeButton("No") { d, _ ->
         d.dismiss()
     }
     .show()
...