From 9e2643df406c2b0032da7f3635f4f651527869eb Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Mon, 27 Feb 2023 13:33:06 +0800 Subject: [PATCH] Fix ActionButtons alignment Let the button text to fill the remaining space and align center, to fix the alignment issue when button text is long. Fix: 270208342 Test: Manually with Gallery Test: Manually with Settings Change-Id: I3be7d3fd5b1f575a467f0ff6289fd868ab2171ff --- .../spa/widget/button/ActionButtons.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/button/ActionButtons.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/button/ActionButtons.kt index 5e6c61423c245..0552c408a8ebf 100644 --- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/button/ActionButtons.kt +++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/button/ActionButtons.kt @@ -24,7 +24,6 @@ import androidx.compose.foundation.layout.IntrinsicSize import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -46,6 +45,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.android.settingslib.spa.framework.theme.SettingsDimension @@ -100,11 +100,16 @@ private fun RowScope.ActionButton(actionButton: ActionButton) { contentDescription = null, modifier = Modifier.size(SettingsDimension.itemIconSize), ) - Spacer(Modifier.height(4.dp)) - Text( - text = actionButton.text, - style = MaterialTheme.typography.labelMedium, - ) + Box( + modifier = Modifier.padding(top = 4.dp).fillMaxHeight(), + contentAlignment = Alignment.Center, + ) { + Text( + text = actionButton.text, + textAlign = TextAlign.Center, + style = MaterialTheme.typography.labelMedium, + ) + } } } }