Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android 15 でアクションバー表示時にステータスバーが白くなってしまう問題

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Android 15 でアクションバー表示時にステータスバーが白くなってしまう問題

Avatar for tonionagauzzi

tonionagauzzi

October 23, 2024

More Decks by tonionagauzzi

Other Decks in Programming

Transcript

  1. レイアウトを調整 override fun onCreate(savedInstanceState: Bundle?) { ... // View をステータスバーの高さぶん下へずらす

    ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.root_view)) { view, windowInsets -> val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()) view.setPadding(insets.left, insets.top, insets.right, insets.bottom) WindowInsetsCompat.CONSUMED } // Android 14以下でもEdge-to-edgeにする(任意) enableEdgeToEdge( statusBarStyle = SystemBarStyle.dark(Color.TRANSPARENT), navigationBarStyle = SystemBarStyle.dark(Color.TRANSPARENT) ) } potatotips #89 7
  2. 1. Edge-to-edge を無効化する <!-- styles.xml --> <?xml version="1.0" encoding="utf-8"?> <resources

    xmlns:tools="http://schemas.android.com/tools"> <style name="Theme.AppCompat.Light.DarkActionBar.OptOutEdgeToEdge" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="android:windowOptOutEdgeToEdgeEnforcement" tools:targetApi="35">true</item> </style> </resources> <!-- AndroidManifest.xml --> <activity android:name=".view.SampleActivity" android:exported="true" android:theme="@style/Theme.AppCompat.Light.DarkActionBar.OptOutEdgeToEdge"> ... </activity> potatotips #89 27
  3. 2. アクションバーを消す 方法はいくつかある o ツールバーに置き換える(XML) o TopAppBarに置き換える(Compose) o アプリバーを自作する o

    アプリバーを使わない見た目にする 対応例はブログにて紹介 https://blog.cybozu.io/entry/2024/10/21/080000#2- %E3%82%A2%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%83%90%E3%83%BC%E3% 82%92%E6%B6%88%E3%81%99 potatotips #89 29