0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Android 4 系で android:actionOverflowButtonStyle や android:homeAsUpIndicator が反映されない

Posted at

テーマでツールバー上にあるアイコンを変えたければ以下のような感じで android:actionOverflowButtonStyle と android:homeAsUpIndicator を設定します。が、これだけだと古い端末で問題があります。

問題について

<style name="orenoActionBarOverflow" parent="android:style/Widget.Holo.ActionButton.Overflow">
  <item name="android:src">@drawable/oreno_overflow_icon</item>
</style>

<style name="OrenoTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:actionOverflowButtonStyle">@style/orenoActionBarOverflow</item>
  <item name="android:actionButtonStyle">@style/orenoActionBarOverflow</item>
  <item name="android:homeAsUpIndicator">@drawable/oreno_back_button</item>
</style>

これだけだと Android 4.0 ~ Android 4.4 までの端末で xml で指定したアイコンが設定されずデフォルトのものが使用されてしまいます。

対処方法

Android 4 系でも反映されるようにするには android: を外した設定も入れる必要があるそうです。以下のような感じです。

<style name="orenoActionBarOverflow" parent="android:style/Widget.Holo.ActionButton.Overflow">
  <item name="android:src">@drawable/oreno_overflow_icon</item>
</style>

<style name="OrenoTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:actionOverflowButtonStyle">@style/orenoActionBarOverflow</item>
  <item name="android:actionButtonStyle">@style/orenoActionBarOverflow</item>
  <item name="android:homeAsUpIndicator">@drawable/oreno_back_button</item>

  <!-- Android 4.0 ~ 4.4 向けにこれが必要! -->
  <item name="actionOverflowButtonStyle">@style/orenoActionBarOverflow</item>
  <item name="homeAsUpIndicator">@drawable/oreno_back_button</item>
</style>

参考文献

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?