我似乎无法让 MediaRoute 按钮在我的实体 ActionBar 中显示为“白色”。
我的问题是:如何在不更改可绘制名称的情况下将 MediaRoute 按钮设置为浅色或深色?
在这里查看类似的问题:如何更改 ActionBar 中 MediaRouteButton 的样式? https://stackoverflow.com/questions/19278319/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/ 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 可绘制对象的位置?