Android、ダークテーマ。ダークモード
少ない開発リソースでAndroidアプリをダークモードに対応した話
これからAndroidでダークモードを実装するエンジニア/デザイナ向け資料
要約
ダークテーマの実装の流れは
- テーマの切り替えを実装して
- ダークテーマ用にリソースを用意して
- レイアウトにあててデザインを確認する
です。
アプリで現在のテーマが何かを調べるには、次のようなコードを実行することができます:
int currentNightMode = configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK;
switch (currentNightMode) {
case Configuration.UI_MODE_NIGHT_NO:
// Night mode is not active, we're using the light theme
break;
case Configuration.UI_MODE_NIGHT_YES:
// Night mode is active, we're using dark theme
break;
}