Skip to content

Fix xml-layout-migration.md#19

Merged
simona-anomis merged 1 commit intomainfrom
anomis/fix-xml-layout-migration
Apr 17, 2026
Merged

Fix xml-layout-migration.md#19
simona-anomis merged 1 commit intomainfrom
anomis/fix-xml-layout-migration

Conversation

@simona-anomis
Copy link
Copy Markdown
Collaborator

No description provided.

@simona-anomis simona-anomis self-assigned this Apr 17, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request corrects markdown syntax and indentation in the XML layout migration documentation. A review comment identifies a discrepancy in how padding is handled when migrating from XML to Jetpack Compose, suggesting the use of the contentPadding parameter instead of Modifier.padding to ensure consistent UI behavior. Additionally, the feedback recommends using named arguments for better readability and replacing hard-coded dimensions with resource references.

Comment on lines +49 to +67
TextButton(
onClick, modifier
.defaultMinSize(minWidth = dimensionResource(R.dimen.min_width))
.padding(
start = dimensionResource(R.dimen.padding_2),
end = dimensionResource(R.dimen.padding_2)
), enabled, shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.textButtonColors(
contentColor = MaterialTheme.colorScheme.primary
)
) {
Text(
text = text,
style = MaterialTheme.typography.bodyMedium.copy(
fontFamily = FontFamily.SansSerif,
fontWeight = FontWeight.Medium
)
)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In Jetpack Compose, Modifier.padding applied to a Button (or TextButton) adds padding outside the component's boundaries, which differs from the internal padding behavior of android:padding in XML. To correctly replicate the XML style's padding, use the contentPadding parameter of the TextButton composable. Additionally, using named arguments for all parameters improves readability and maintainability. Note that per the guide's instructions on line 14, hard-coded values like 8.dp should ideally be replaced with dimension resources for consistency.

    TextButton(
        onClick = onClick,
        modifier = modifier.defaultMinSize(minWidth = dimensionResource(R.dimen.min_width)),
        enabled = enabled,
        shape = RoundedCornerShape(8.dp),
        colors = ButtonDefaults.textButtonColors(
            contentColor = MaterialTheme.colorScheme.primary
        ),
        contentPadding = PaddingValues(
            start = dimensionResource(R.dimen.padding_2),
            end = dimensionResource(R.dimen.padding_2)
        )
    ) {
        Text(
            text = text,
            style = MaterialTheme.typography.bodyMedium.copy(
                fontFamily = FontFamily.SansSerif,
                fontWeight = FontWeight.Medium
            )
        )
    }

@simona-anomis simona-anomis merged commit b281881 into main Apr 17, 2026
2 checks passed
@simona-anomis simona-anomis deleted the anomis/fix-xml-layout-migration branch April 17, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants