我要如何改变MediaRouteButton在动作条的风格? [英] How do I change the style of the MediaRouteButton in the ActionBar?

查看:644
本文介绍了我要如何改变MediaRouteButton在动作条的风格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到我可能做一些根本性的错误的风格和主题,但我还是有点一款Android新手,所以请原谅我的无知。我试图从默认的黑暗改变我MediaRouteButton的风格来点亮,因为我有一个轻动作条。我MediaRouteButton是在动作条实施如下:

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 change the style of my MediaRouteButton from the default dark to light since I have a light ActionBar. My MediaRouteButton is implemented in the ActionBar as follows:

<item
    android:id="@+id/menu_item_cast"
    android:actionProviderClass="android.support.v7.app.MediaRouteActionProvider"
    android:actionViewClass="android.support.v7.app.MediaRouteButton"
    android:showAsAction="always"
    android:actionButtonStyle="@android:style/Theme.MediaRouter.Light"/>

不过,这给了我:

However, this gives me:

安卓/ RES /菜单/ main.xml中:24:错误:错误:未发现的资源匹配给定名称(在'actionButtonStyle,值为@android:风格/ Theme.MediaRouter.Light)。

android/res/menu/main.xml:24: error: Error: No resource found that matches the given name (at 'actionButtonStyle' with value '@android:style/Theme.MediaRouter.Light').

推荐答案

如果您不希望更改图标的颜色,框架会选择正确的一个根据你的动作条的主题(深或浅),所以光背景的动作条,它会选择一个较深的图标,反之亦然;这里有两个不同的主题,Theme.AppCompat.Light和Theme.AppCompat,分别为一个示例应用程序(其他一切都是一样的):

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):

正如你所看到的,恰当的一项是自动选择。如果你想使用基于你的品牌要求不同的颜色,最简单的将是如下图像添加到您的项目(下MDPI与通常的决议,华电国际,..):

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

(如果你使用的是光动作条的主题,将暗与光)。看看该资产<一href="https://developers.google.com/cast/docs/downloads">https://developers.google.com/cast/docs/downloads (部分角色图标),得到的感觉是什么,这些图像和建立自己的人根据这些。

(if you are using a light actionbar theme, replace "dark" with "light"). Take a look at the assets at https://developers.google.com/cast/docs/downloads (section Cast Icons) to get a feel for what these images are and build your own ones based on those.

这篇关于我要如何改变MediaRouteButton在动作条的风格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆