4

My app uses Material 3; however, I'm also using some libraries that use Material 2. The problem is: to get colors with Material 3 you have to use MaterialTheme.colorScheme, but to get them with Material 2 you have to use MaterialTheme.colors. So, the libraries that use Material 2 use MaterialTheme.colors, but when I create my theme I use MaterialTheme.colorScheme:

val DarkColorScheme = darkColorScheme(
    primary = Green,
    secondary = Blue,
    tertiary = Red,
    onSurface = Color.White,
    error = Red,
)

@Composable
fun StarDictTheme(
    darkTheme: Boolean = true,
    // Dynamic color is available on Android 12+
    dynamicColor: Boolean = true,
    content: @Composable () -> Unit
) {
    MaterialTheme(
        colorScheme = DarkColorScheme,
        typography = Typography,
        content = content
    )
}

So, in the end the libraries don't use my theme colors, and I get dark elements on a dark background.

Is it possible to fix this? Thanks!

acmpo6ou
  • 840
  • 1
  • 12
  • 21

0 Answers0