Material You – Dynamic Colors with JetPack Compose | by Praveen G | Feb, 2022 | Medium

How one can use dynamic colours in Android apps

Sample screenshot from app
Screenshot from the pattern app, try here

Materials You’s algorithm extracts colours from the consumer’s wallpaper and assigned a kind that determines the way it pertains to a colour scheme. These colour values are then translated into luminance-based tonal palettes, producing 5 colour ranges with tones from mild to darkish.

The screenshot is taken from Material Theme Builder

Like all the time, let’s begin with the required dependencies

// Required minimal model: 1.5.0
implementation 'com.google.android.materials:materials:1.5.0'
// To be used of Material3 in Compose
implementation 'androidx.compose.material3:material3:1.0.0-alpha05'
personal val LightThemeColors = lightColorScheme(
main = md_theme_light_primary, // and 20+ extra colour schemes
)
personal val DarkThemeColors = lightColorScheme(
main = md_theme_light_primary, // and 20+ extra colour schemes
)
import androidx.compose.material3.*
import androidx.compose.materials.*
setContent 
AppTheme
Floor(
modifier = Modifier.fillMaxSize()
)
MyAppScreen()


Scaffold(
topBar =
CustomTopBar()
,
backgroundColor = MaterialTheme.colorScheme.floor
)
Screenshot 1 from the pattern app, try here
Screenshot 2 from the pattern app, try here

More Posts