アクションメニューの背景色を変更したい

1,249 views
Skip to first unread message

ジュラルミン

unread,
Feb 16, 2014, 9:07:29 PM2/16/14
to android-g...@googlegroups.com
アクションバーのアクションメニュー部分の背景色のみを黒くしたいのですが、
どうもうまくできません。(アクションメニュー以外は青系の色に設定しています)
アクションメニューは、「splitActionBarWhenNarrow」にて下部に表示しています。

下記にstyles.xmlに記載している内容を記載しますので、よろしくお願いします。

    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        <item name="android:textColor">@color/fontcolor</item>
        <item name="android:background">@color/normalbg</item>
        <item name="android:fadeScrollbars">false</item>
        <item name="android:actionMenuTextColor">@color/fontcolor</item>
        <item name="android:actionBarStyle">@style/my_actionbar_style</item>
    </style>
    
    <style name="my_actionbar_style" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@color/normalbg</item>
        <item name="android:actionBarItemBackground">@drawable/actionbar_menu_item</item>
        <item name="android:backgroundSplit">@drawable/actionbar_menu_item</item>
        <item name="android:titleTextStyle">@style/my_actionbar_titletextstyle</item>
    </style>
    <style name="my_actionbar_titletextstyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/fontcolor</item>
<item name="android:textStyle">bold</item>
    </style>

「@drawable/actionbar_menu_item」の中身
<?xml version="1.0" encoding="utf-8"?>
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/black" />
        </shape>
    </item>
</selector>

noxi

unread,
Feb 17, 2014, 11:10:22 AM2/17/14
to android-g...@googlegroups.com
noxiです。

ThemeのactionButtonStyleを上書きすれば可能っぽいです。
API19で確認出来ました。
少なくとも、アプリアイコンの後ろが真っ黒になることは無いです。
https://gist.github.com/noxi515/9053201


###
今回確認するのにAndroidStudioを使いました。
スタイル等の名前をCtrl + クリックでAndroidのリソースファイルにもアクセス出来ます。

私がスタイルを設定する際、ググっても良い記事に巡り会えなかったら
ひたすらparentに辿っていってそのスタイルがどんな属性を持っているのか、
またはそれっぽい名前を見つけ、それがどこで設定されているかを探します。
余程酷い名前で無い限り、意外とすぐに見つかります。


他の人はこういうのをどうやって探しているのか、私気になります。


2014年2月17日 11:07 ジュラルミン <duralum...@gmail.com>:
> --
> このメールは Google グループのグループ「日本Androidの会」の登録者に送られています。
> このグループから退会し、メールの受信を停止するには、android-group-j...@googlegroups.com
> にメールを送信します。
> このグループに投稿するには、android-g...@googlegroups.com にメールを送信してください。
> http://groups.google.com/group/android-group-japan からこのグループにアクセスしてください。
> その他のオプションについては、https://groups.google.com/groups/opt_out にアクセスしてください。

ジュラルミン

unread,
Feb 17, 2014, 8:42:00 PM2/17/14
to android-g...@googlegroups.com, android.w...@gmail.com
noxiさん、回答及びサンプルコードありがとうございます。
おかげさまで、無事色を変えることができました!
 
まだ始めたばかりでお恥ずかしい話、
「AndroidStudio」なるものも知りませんでしたので、
これから色々と勉強させていただきたいと思います。
 
Reply all
Reply to author
Forward
0 new messages