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
This commit is contained in:
Chaohui Wang
2023-02-27 13:33:06 +08:00
parent ef75be3981
commit 9e2643df40

View File

@@ -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,
)
}
}
}
}