【发布时间】:2014-09-01 12:57:38
【问题描述】:
我似乎无法让 MediaRoute 按钮在我的实体 ActionBar 中显示为“白色”。
我的问题是:我们如何在不更改可绘制名称的情况下将 MediaRoute 按钮设置为浅色或深色?
在这里查看一个类似的问题:How do I change the style of the MediaRouteButton in the ActionBar? 接受的解决方案只是使用您自己的一组 MediaRoute 可绘制对象,并将名称交换为 lightdark。
对于我的应用,我有 3 种不同的样式:light-ActionBar、dark-ActionBar 和 light-solid-ActionBar。我不能简单地交换可绘制名称,因为我需要深色和浅色才能正确显示前两个主题。为了正确显示实体操作栏内容,我正在做这样的事情:(在此处找到以下示例:http://www.jayway.com/2014/06/02/android-theming-the-actionbar/)
//Parent Light.DarkActionBar should give white ActionBar icons
<style name="AppTheme.Solid.Light" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/Widget.Solid.ActionBar</item>
<item name="android:actionBarWidgetTheme">@style/ActionBarWidget</item>
.
.
//Make the ActionBar solid, but need to use 'inverse' to keep the icons/text white
<style name="Widget.Solid.ActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
.
.
//**** THE ISSUE IS CAUSED BY USING THE FOLLOWING
//Make the ActionBar dropdown spinner items use the correct (white) theme as well
<style name="ActionBarWidget" parent="Theme.AppCompat.Light.DarkActionBar">
.
.
ActionBarWidget 主题是确保 ActionBar 溢出图标下拉菜单背景显示为白色而不是黑色所必需的。但是,它会导致 MediaRoute 按钮更改为它的深色主题可绘制对象,这不适合。
我尝试过覆盖 Widget.MediaRouter.MediaRouteButton 并强制 <item name="externalRouteEnabledDrawable">@drawable/mr_ic_media_route_holo_dark</item>,但我所做的没有任何影响。
如何在不更改可绘制名称的情况下为 MediaRoute 按钮设置浅色或深色样式? 是否有一种简单的样式可以覆盖我们可以设置自己的 MediaRoute 可绘制对象的位置?
【问题讨论】:
标签: android android-theme chromecast android-styles