• ױ, Light ప݃݅ ForceDarkо ਊؼ ࣻ . <style name="AppTheme" parent="@style/Theme.MaterialComponents.Light> <item name="android:forceDarkAllowed">true</item> </style> Enable Force Dark F O R C E D A R K <style name="Theme.AppCompat.Light" parent="..."> <item name="isLightTheme">true</item> </style>
D A R K • Force Darkܳ ࠗ࠙ਵ۽ ઁ৻ೡ ࣻ . // For Kotlin view.isForceDarkAllowed = false // For Java view.setForceDarkAllowed(false) <!-- For Layout XML --> <View android:forceDarkAllowed="false" /> • ViewGroupী ਊೞݶ ೞਤ View ݽفী ਊغ݅, true۽ ࢸೞݶ ࠗݽ/ध View falseܳ ޖदೠ.
abstract void setLocalNightMode(@NightMode int mode); public static void setDefaultNightMode(@NightMode int mode) { ... } • ଵҊ: ч in-memoryী غ۽, ߹ب۽ чਸ /ࠂҳ ೧ঠ ೠ. Set / Get night mode D A Y N I G H T • ప݃ ৈࠗܳ ഛੋೞח ߑߨ fun isDarkTheme(config: Configuration): Boolean { return config.uiMode and // andח &৬ زੌ Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES }
. Manual DayNight D A Y N I G H T <!-- AndroidManifest.xml --> <activity android:name=“.MainActivity" android:configChanges="uiMode" /> class MainActivity : AppCompatActivity() { override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) val isDarkTheme: Boolean = isDarkTheme(newConfig) ... UI সؘ ... } }
E S E T T I N G MODE_NIGHT_YES MODE_NIGHT_NO MODE_NIGHT_FOLLOW_SYSTEM MODE_NIGHT_AUTO_BATTERY • যنѱ • ߋѱ • दझమ ࢸ • ݽ٘ ࢸ • п ࢸী ೧ೞח Night Modeܳ ଵҊೞࣁਃ. = = = = ࢸч द -> light -> dark -> default -> default
ਊೠ. • MaterialShapeDrawable, ElevationOverlayProviderܳ ਊೞݶ Custom Viewী Elevation Overlaysܳ ࣚऔѱ ਊೡ ࣻ . • ਗ ঋח ҃, elevationOverlaysEnabled ࣘࢿਸ false۽ ߸҃ೞݶ ػ. <style name="Theme.MaterialComponents" parent="..."> <item name="elevationOverlaysEnabled">true</item> <item name="elevationOverlaysColor">?attr/colorOnSurface</item> </style> Elevation Overlays E L E V A T I O N
Bar • Bottom App Bar • Bottom Navigation • Tabs • Card • Dialog • Menu • Bottom Sheet • Navigation Drawer • Switch Elevation Overlays Components E L E V A T I O N
ࢴযળ. MDC 1.1.0 @ColorInt // layered color, if elevationOverlaysEnabled == true public int layerOverlayIfNeeded(@ColorInt int bgColor, float elevation) @ColorInt // layered color, always public int layerOverlay(@ColorInt int bgColor, float elevation) @ColorInt // layered color, of attr/colorSurface public int getSurfaceColorWithOverlayIfNeeded(float elevation) class
https://material.io/design/color/dark-theme.html https://material.io/develop/android/theming/dark/ • DayNight - Adding a dark theme to your app https://medium.com/androiddevelopers/d10f90c83e94 • IO19 - Dark Theme & Gesture Navigation https://youtu.be/OCHEjeLC_UY • IO19 - How to design a Dark Theme https://youtu.be/9NDLR3COU7Y