Skip to main content

Posts

Showing posts with the label Jetpack Compose

Preventing MIUI Forced Dark Mode from Breaking Your Android UI

  You have just finished polishing a meticulously crafted application. The colors follow strict accessibility contrast ratios, the typography is crisp, and you have manually implemented a robust Android dark mode. It looks perfect on Google Pixel and Samsung Galaxy devices. Then, a user opens your app on a Xiaomi device running MIUI or HyperOS. Suddenly, your white text on a dark gray background turns into dark gray text on a pitch-black background. Your carefully designed icons are inverted, and the application is rendered completely unusable. This occurs because MIUI utilizes an aggressive "Force Dark Mode" feature at the system level. Even if your application explicitly defines its own dark theme parameters, the operating system intercepts the rendering pipeline and dynamically inverts the colors. For engineers focused on precise Android UI design, this is a critical rendering bug. This article breaks down the root cause of this behavior and provides a definitive, producti...

Jetpack Compose Performance: Strong Skipping Mode & Layout Optimization

  There is nothing more frustrating in Android development than building a beautiful, declarative UI only to watch it stutter during a simple scroll. You’ve optimized your business logic, moved heavy operations to background threads, and yet the Android Profiler shows skipped frames. For years, the "magic" of Jetpack Compose came with a hidden tax:  Stability . If the Compose compiler could not prove a data type was immutable, it pessimistically assumed the data changed on every frame, triggering unnecessary recomposition. With the arrival of Kotlin 2.0 and the Compose Compiler Gradle plugin, we have a new paradigm:  Strong Skipping Mode . Combined with proper usage of  derivedStateOf , we can virtually eliminate UI jank without boilerplate wrapper classes. The Root Cause: Why "Jank" Happens To fix performance, you must understand the Compose phases. Frame drops usually occur during the  Composition  phase, before Layout or Draw. When a parent composable re...