How do I change the style of the MediaRouteButton in the ActionBar?

后端 未结 6 398
一向
一向 2020-12-03 21:58

I realize I\'m probably doing something fundamentally wrong with styles and themes but I\'m still a bit of an Android newbie so please excuse my ignorance. I\'m trying to c

6条回答
  •  甜味超标
    2020-12-03 22:03

    If you don't want to change the color of the icon, framework would choose the right one (dark or light) based on the theme of your actionbar, so for an actionbar with light background, it will choose a darker icon and vice versa; here is a sample app with two different themes, Theme.AppCompat.Light and Theme.AppCompat, respectively (everything else is identical):

    This is with Theme.AppCompat.Light theme

    This is with Theme.AppCompat

    As you can see, the appropriate one is selected automatically. If you want to use a different color based on your branding requirements, the easiest would be to add the following images to your project (with usual resolutions under mdpi, hdpi, ..):

    • mr_ic_media_route_disabled_holo_dark.png
    • mr_ic_media_route_off_holo_dark.png
    • mr_ic_media_route_on_0_holo_dark.png
    • mr_ic_media_route_on_1_holo_dark.png
    • mr_ic_media_route_on_2_holo_dark.png

    (if you are using a light actionbar theme, replace "dark" with "light"). Take a look at the assets at Google Cast > Sample Apps (section Cast Icons) to get a feel for what these images are and build your own ones based on those.

提交回复
热议问题