说我有一个菜单(options_menu.xml)类似以下内容:
<菜单的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto>
<项目机器人:ID =@ + ID / action_login
机器人:标题=登陆
应用程序:showAsAction =总是/>
< /菜单>
我膨胀到新的工具栏项目
mToolbar.inflateMenu(R.menu.options_home);
这导致像
有没有办法来改变这种文字颜色的没有的使用图像,改变工具栏文字颜色的休息,或通过添加自定义视图的工具栏?正在寻找minSdk 15(appcompat)的答案。
更新:
我的有关方式:
<样式名称=AppTheme父=AppTheme.Base>
<项目名称=actionMenuTextColor> @色/ ww_red< /项目>
< /风格>
<样式名称=AppTheme.Base父=Theme.AppCompat.Light.NoActionBar>
<项目名称=colorPrimary> @色/红色和LT; /项目>
<项目名称=colorAccent> @色/ theme_accent< /项目>
<项目名称=机器人:文字颜色> @色/ text_dark< /项目>
<项目名称=机器人:colorEdgeEffect> @彩色/灰度< /项目>
< /风格>
解决方案
在你的主题文件,你必须把这样的:
<样式名称=AppTheme.ActionBar父=Theme.AppCompat.Light.DarkActionBar>
...
<项目名称=actionMenuTextColor> @色/ text_color< /项目>
...
< /样式和GT;`
和应用这一主题,以这样的工具栏查看:
< android.support.v7.widget.Toolbar的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:ID =@ + ID / main_toolbar
机器人:layout_width =match_parent
机器人:layout_height =?ATTR / actionBarSize
机器人:ATTR / colorPrimary后台=
机器人:layout_gravity =顶
应用程序:popupTheme =@风格/ ThemeOverlay.AppCompat.Light
机器人:主题=@风格/ AppTheme.ActionBar/>
机器人:主题=@风格/ AppTheme.ActionBar不要忘了此行的工具栏
Say I have a menu (options_menu.xml) similar to the following:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item android:id="@+id/action_login"
android:title="Login"
app:showAsAction="always"/>
</menu>
which I inflate into the new Toolbar item
mToolbar.inflateMenu(R.menu.options_home);
This results in something like
Is there a way to change this text color without using an image, changing the rest of the Toolbar text color, or by adding a custom view to the toolbar? Looking for an answer for minSdk 15 (appcompat).
Update:
My relevant style:
<style name="AppTheme" parent="AppTheme.Base">
<item name="actionMenuTextColor">@color/ww_red</item>
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/red</item>
<item name="colorAccent">@color/theme_accent</item>
<item name="android:textColor">@color/text_dark</item>
<item name="android:colorEdgeEffect">@color/gray</item>
</style>
解决方案
In your theme file you have to put this :
<style name="AppTheme.ActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="actionMenuTextColor">@color/text_color</item>
...
</style>`
and apply this theme to your Toolbar view like this :
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:layout_gravity="top"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:theme="@style/AppTheme.ActionBar"/>
android:theme="@style/AppTheme.ActionBar" don't forget this line in your toolbar
上一篇:AudioRecorder在Android的错误无效的缓冲区大小缓冲区、大小、错误、AudioRecorder
下一篇:ActivityOptions.makeSceneTransitionAnimation似乎并不存在并不、存在、ActivityOptions、makeSceneTransitionAnimation