修改风格不能很好地工作 [英] Modifying style does not work well
问题描述
我改变了我的应用程序的用户界面,以绿色。在动作条,我使用ShareActionProvider共享数据给其他用户,但是,该菜单项没有得到相同的颜色作为其他菜单项。然而,它的下拉列表视图是否具有正确的颜色。
我跑我的姜饼的应用程序,所以当我preSS菜单键,菜单项出现,但它也有错误的颜色。
我已经使用 Android的动作栏样式生成器,但有我丢失的东西。这是我的code在/ RES /值:
<资源的xmlns:机器人=http://schemas.android.com/apk/res/android>
&所述;! - 应用于应用程序或活动的主题 - >
<样式名称=CustomActionBarTheme父=@风格/ Theme.AppCompat.Light.DarkActionBar>
<项目名称=actionBarItemBackground> @可绘制/ selectable_background_newtheme< /项目>
<项目名称=actionBarStyle> @风格/ ActionBar.Solid.NewTheme< /项目>
<项目名称=popupMenuStyle> @风格/ PopupMenu.NewTheme< /项目>
<项目名称=dropDownListViewStyle> @风格/ DropDownListView.NewTheme< /项目>
<项目名称=actionDropDownStyle> @风格/ DropDownNav.NewTheme< /项目>
<! - Light.DarkActionBar具体 - >
<项目名称=actionBarWidgetTheme> @风格/ NewTheme.Widget< /项目>
< /风格>
<! - 动作条的风格 - >
<样式名称=ActionBar.Solid.NewTheme父=@风格/ Widget.AppCompat.Light.ActionBar.Solid.Inverse>
<项目名称=背景> @可绘制/ action_bar_gradient< /项目>
< /风格>
<样式名称=PopupMenu.NewTheme父=@风格/ Widget.AppCompat.PopupMenu>
<项目名称=机器人:popupBackground> @可绘制/ background_gradient< /项目>
< /风格>
<样式名称=DropDownListView.NewTheme父=@风格/ Widget.AppCompat.ListView.DropDown>
<项目名称=机器人:listSelector> @可绘制/ selectable_background_newtheme< /项目>
< /风格>
<样式名称=DropDownNav.NewTheme父=@风格/ Widget.AppCompat.Spinner.DropDown.ActionBar>
<项目名称=机器人:背景> @可绘制/ spinner_background_ab_newtheme< /项目>
<项目名称=机器人:dropDownSelector> @可绘制/ selectable_background_newtheme< /项目>
< /风格>
<! - 这种风格只引用一个Light.DarkActionBar基于主题 - >
<样式名称=NewTheme.Widget父=@风格/ Theme.AppCompat>
<项目名称=popupMenuStyle> @风格/ PopupMenu.NewTheme< /项目>
<项目名称=dropDownListViewStyle> @风格/ DropDownListView.NewTheme< /项目>
< /风格>
有没有缺失的项目?在此先感谢
我终于得到了它的工作我自己。我不得不添加:
&LT;项目name="android:listChoiceBackgroundIndicator">@drawable/selectable_background_realestate</item>
在* themes_base.xml *价值观-V14和
&LT;项目名称=listChoiceBackgroundIndicator&GT; @可绘制/ selectable_background_realestate&LT; /项目&GT;
在themes_base.xml为当pressing列表项正确高亮颜色值。
我也不得不改变的 actionBarItemBackground 的在themes_base.xml(价值和价值观,V14),以引用我的绘制,这样的共享图标会得到相同的亮点。
最后得到的下拉菜单项,我不得不改变的的Android正确的颜色:popupBackground 的为@绘制/ menu_dropdown_panel_realestate在styles_base.xml(价值和价值观,V14)的窗口小部件。 AppCompat.Base.ListPopupWindow 的
使用 Android的资产工作室获得AppCompat 生成我在回答中引用的可绘P>
I'm changing the UI of my app to green colors. In the ActionBar, I use a ShareActionProvider to share data to other users, but this menu item doesn't get the same color as the other menu items. However, its dropdown listview has the correct colors.
I'm running my app in GingerBread, so when I press menu key, a menu item appears but it also has the wrong colors.
I have used Android Action Bar Style Generator, but there is something I'm missing. This is my code in /res/values:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">@drawable/selectable_background_newtheme</item>
<item name="actionBarStyle">@style/ActionBar.Solid.NewTheme</item>
<item name="popupMenuStyle">@style/PopupMenu.NewTheme</item>
<item name="dropDownListViewStyle">@style/DropDownListView.NewTheme</item>
<item name="actionDropDownStyle">@style/DropDownNav.NewTheme</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">@style/NewTheme.Widget</item>
</style>
<!-- ActionBar style -->
<style name="ActionBar.Solid.NewTheme" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">@drawable/action_bar_gradient</item>
</style>
<style name="PopupMenu.NewTheme" parent="@style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">@drawable/background_gradient</item>
</style>
<style name="DropDownListView.NewTheme" parent="@style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_newtheme</item>
</style>
<style name="DropDownNav.NewTheme" parent="@style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">@drawable/spinner_background_ab_newtheme</item>
<item name="android:dropDownSelector">@drawable/selectable_background_newtheme</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="NewTheme.Widget" parent="@style/Theme.AppCompat">
<item name="popupMenuStyle">@style/PopupMenu.NewTheme</item>
<item name="dropDownListViewStyle">@style/DropDownListView.NewTheme</item>
</style>
Is there any missing item? Thanks in advance
I finally got it working myself. I had to add:
<item name="android:listChoiceBackgroundIndicator">@drawable/selectable_background_realestate</item>
in *themes_base.xml* in values-v14 and
<item name="listChoiceBackgroundIndicator">@drawable/selectable_background_realestate</item>
in themes_base.xml in values for the correct highlight color when pressing a list item.
I also had to change actionBarItemBackground in themes_base.xml (values and values-v14) to reference my drawable so that the share icon would get the same highlight.
Finally to get the right color of the dropdown menu item I had to change android:popupBackground to @drawable/menu_dropdown_panel_realestate in styles_base.xml (values and values-v14) for Widget.AppCompat.Base.ListPopupWindow
The drawables I referenced in my answer were generated using Android Asset Studio for AppCompat
这篇关于修改风格不能很好地工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!