4
5

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 アクションバーのメニューアイコンの変更方法

Posted at

Androidのメニューで使われているアイコン(three dots)を変更したい!

Screenshot_2016-12-12-12-44-43.jpeg
これを↓
Screenshot_2016-12-12-12-45-29.jpeg
こんな感じに自由に変更したい

標準のメニューバー

menu_main.xml

qiita.rb
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="xxx.xxx">
    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:title="@string/action_settings"
        app:showAsAction="never" />

</menu>

カスタマイズ

menu_main.xml

qiita.rb
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="xxx.xxx">
    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:title="@string/action_settings"
        android:icon="変更したいアイコン"
        app:showAsAction="always" >

        <menu>
            <item android:id="@+id/action_menu1"
                android:icon="@android:drawable/ic_menu_preferences"
                android:title="menu setting" />
            <item android:id="@+id/action_menu2"
                android:icon="@android:drawable/ic_menu_help"
                android:title="help" />
        </menu>
    </item>
</menu>

大きなitemの中にさらにmenuを作成し、そこに作りたいメニューを追加。
そして、常に表示するためにapp:showAsActionをalwaysに。

4
5
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
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?