Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Document how to manage Material3 typography #352

Open
dfabulich opened this issue Feb 21, 2025 · 0 comments
Open

docs: Document how to manage Material3 typography #352

dfabulich opened this issue Feb 21, 2025 · 0 comments

Comments

@dfabulich
Copy link

To edit Android fonts, especially navigation titles and tab bar titles, you have to edit your Main.kt and edit typography settings there. This should be in the docs somewhere.

@Composable
internal fun PresentationRootView(context: ComposeContext) {
    val colorScheme = if (isSystemInDarkTheme()) ColorScheme.dark else ColorScheme.light

    val typography = androidx.compose.material3.Typography(
        // nav title (large)
        headlineLarge = androidx.compose.ui.text.TextStyle(
            fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace,
            fontWeight = androidx.compose.ui.text.font.FontWeight.Bold
        ),
        // nav title (smaller)
        headlineMedium = androidx.compose.ui.text.TextStyle(
            fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace,
            fontWeight = androidx.compose.ui.text.font.FontWeight.Bold
        ),
        // tab title
        labelMedium = androidx.compose.ui.text.TextStyle(
            fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace,
            fontWeight = androidx.compose.ui.text.font.FontWeight.Bold
        )
    )

    androidx.compose.material3.MaterialTheme(typography = typography) {
        PresentationRoot(defaultColorScheme = colorScheme, context = context) { ctx ->
            val contentContext = ctx.content()
            Box(modifier = ctx.modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
                RootView().Compose(context = contentContext)
            }
        }
    }
}
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

No branches or pull requests

1 participant