一键导入
android-rotation-anti-flicker
Eliminate black flash and visual glitches during screen rotation in Android apps
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Eliminate black flash and visual glitches during screen rotation in Android apps
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Guidance for creating effective modular skills for Claude. Use when creating or refining skills to ensure they are concise, follow progressive disclosure patterns, and provide appropriate degrees of freedom.
Guidelines for ensuring smooth and race-condition-free theme transitions in Android, specifically regarding icon tinting and state management.
Best practices for effective human-AI pair programming and communication
Clarify touch-target vs visual size when users ask to resize buttons without changing icons.
Choose whether the outer container acts as the touch proxy or remains a layout placeholder to control hit targets.
Best practices for 60fps custom View rendering with zero allocation in onDraw
| name | Android Rotation Anti-Flicker |
| description | Eliminate black flash and visual glitches during screen rotation in Android apps |
| last_verified | "2026-01-23T00:00:00.000Z" |
| applicable_sdk | Android 8+ (API 26+) |
Last Verified: 2026-01-23 Applicable SDK: Android 8+ (API 26+), tested through Android 15 (API 35) Project Context: OpenFlip (Target SDK 35, Min SDK 26)
This skill provides a proven protocol to eliminate black screen flashes and visual glitches during screen rotation in Android applications.
Required Skills:
Related Skills:
New Behaviors:
Compatibility: All techniques in this skill remain valid for Android 15.
Add configChanges to prevent Activity recreation:
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:screenOrientation="fullSensor" />
Why: Prevents Activity destruction/recreation cycle that causes black screen.
values/themes.xml)<style name="AppTheme" parent="Theme.Material3.Light.NoActionBar">
<item name="android:windowBackground">@color/white</item>
</style>
values-night/themes.xml)<style name="AppTheme" parent="Theme.Material3.Dark.NoActionBar">
<item name="android:windowBackground">@color/black</item>
</style>
[!CAUTION] NEVER use
?attr/colorSurfaceor any dynamic attribute forwindowBackground. Dynamic attributes are resolved during rotation, causing a brief flash.
Apply to animation-heavy custom views:
class MyCustomView(context: Context, attrs: AttributeSet?) : View(context, attrs) {
init {
setLayerType(LAYER_TYPE_HARDWARE, null)
}
}
Why: Prevents GPU resource deallocation after idle periods. Without this, rotating after 10+ seconds of inactivity causes black flash as GPU re-rasterizes.
Override onConfigurationChanged instead of relying on Activity recreation:
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
// Recalculate dimensions, refresh layouts
myCustomView.requestLayout()
}
| Symptom | Cause | Fix |
|---|---|---|
| Black flash on first rotation | Missing windowBackground | Add hardcoded color in themes.xml |
| Flash after idle | GPU layer reclaimed | Add LAYER_TYPE_HARDWARE |
| Delayed rotation response | Activity recreating | Add configChanges in manifest |