下の画像に示すように、アクションバーの右端にあるオーバーフローメニューアイコンを変更するにはどうすればよいですか?私のホロテーマは、デフォルトでこの3行の黒いスタックアイコンを指定していますが、何か他のものが必要です。私はこれに対する解決策を見つけることができないようです。 http://developer.Android.com/guide/topics/ui/menus.html のドキュメントを見てきましたが、あまり役に立たないようです。
ありがとう!
カスタムスタイルを定義します。たとえば、それをcustomoverflow
と呼びましょう。
このスタイルでは、使用したい画像にAndroid:src
を設定します。次に、親Theme.holo
でスタイルを作成します。
このスタイルでは、以下を定義する必要があります。
<item name="Android:actionOverflowButtonStyle">@style/customoverflow</item>
私はこれをテストしたところ、動作します。
あなたはこのようなことを試すことができます:
<style name="MyTheme" parent="Android:style/Theme.Holo.Light">
<item name="Android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
</style>
<style name="MyActionButtonOverflow" parent="Android:style/Widget.Holo.ActionButton.Overflow">
<item name="Android:src">@drawable/my_action_bTutton_overflow</item>
</style>
およびAndroidManifest.xml
<application
Android:theme="@style/MyTheme" >
AppCompatを使用している場合は、次のコードで実現できます。
res/values/themes.xml
<style name="MyTheme" parent="@style/Theme.AppCompat.Light">
<item name="Android:actionOverflowButtonStyle">@style/ActionButtonOverflow</item>
<!-- Support library compatibility -->
<item name="actionOverflowButtonStyle">@style/ActionButtonOverflow</item>
</style>
<style name="ActionButtonOverflow" parent="@style/Widget.AppCompat.ActionButton.Overflow">
<item name="Android:src">@drawable/ic_launcher</item>
</style>
およびandroidmanifest.xml
<application
Android:theme="@style/MyTheme" >
アプリのテーマがHoloの場合は白くなりますが、Holo.Lightの場合は黒っぽくなります。
ただし、アクションバーのスタイルを変更してHoloから継承し、アプリの残りの部分をHolo.Lightから継承しても問題は解決しませんが、変更するスタイルの方向を示す必要があります。
私が試したことは:
<style name="AppThemeLight" parent="Android:style/Theme.Holo.Light">
<item name="Android:actionBarStyle">@style/ActionBar</item>
<item name="Android:windowContentOverlay">@drawable/actionbar_shadow</item>
</style>
<style name="ActionBar" parent="Android:style/Widget.Holo.Light.ActionBar">
<item name="Android:background">@color/header_brown</item>
<item name="Android:titleTextStyle">@style/ActionBarTitle</item>
<item name="Android:icon">@drawable/header</item>
</style>
私は同じ問題を抱えており、これは解決策に近いと思います
基本的に、新しいAPIレベルで利用可能なテーマのカスタマイズはres/values-vXX/styles.xml
、下位互換性に関連するカスタマイズはvalues/styles.xml
Shalafiのソリューションは、いくつかの追加で機能します。したがって、このコードを両方に追加しますres/values-vXX/styles.xml
およびres/values/styles.xml
そしてこれは魔法のように機能します!
<style name="AppTheme" parent="Android:style/Theme.Holo.Light">
<item name="Android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
</style>
<style name="MyActionButtonOverflow"parent="Android:style/Widget.Holo.ActionButton.Overflow">
<item name="Android:src">@drawable/your_overflow_icon</item>
</style>
androidManifest.xmlにも追加します
<application
Android:theme="@style/AppTheme" >
重複する質問、 アクションバーのオーバーフローアイコンの変更
これが私の答えです。
Styles.xmlのアクションバーのカスタムオーバーフローアイコンを変更します
<resources>
<!-- Base application theme. -->
<style name=“MyTheme" parent="@Android:style/Theme.Holo">
<!-- Pointer to Overflow style DONT forget! -->
<item name="Android:actionOverflowButtonStyle">@style/MyOverFlow</item>
</style>
<!-- Styles -->
<style name="MyOverFlow" parent="@Android:style/Widget.Holo.ActionButton.Overflow">
<item name="Android:src">@drawable/ic_your_action_overflow</item>
</style>
</resources>
AndroidManifest.xmlのアプリケーションタグにカスタムテーマ「MyTheme」を配置します
<application
Android:name="com.example.Android.MainApp"
Android:theme="@style/AppTheme">
</application>
楽しんで。@。@
<style name="ToolBarTheme" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="Android:tint">@color/colorAccent</item>
上記のtheme.setの色合いを自分の色で作成し、このテーマをツールバーに追加します。
<androidx.appcompat.widget.Toolbar
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:minHeight="?attr/actionBarSize"
Android:theme="@style/ToolBarTheme"/>
Shalafiのソリューションは、いくつかの変更で機能します。テーマの親としてtheme.Holoを指定する必要がありますが、デフォルトのテキストの色を変更するという欠点があります(少なくとも私のスタイルでは)。
修正されたコードは次のようになります。
<style name="AppThemeLight" parent="Android:style/Theme.Holo">
<item name="Android:actionBarStyle">@style/ActionBar</item>
<item name="Android:windowContentOverlay">@drawable/actionbar_shadow</item>
</style>
<style name="ActionBar" parent="Android:style/Widget.Holo.Light.ActionBar">
<item name="Android:background">@color/header_brown</item>
<item name="Android:titleTextStyle">@style/ActionBarTitle</item>
<item name="Android:icon">@drawable/header</item>
</style>