如何设置Android ActionBar溢出菜单的样式(背景颜色,文本颜色,自定义绘图等)?
我一直在尝试使用以下样式执行此操作,但似乎没有任何效果。任何帮助将不胜感激。
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarWidgetTheme">@style/MyActionBar</item>
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:textColor">@android:color/holo_blue_light</item>
<item name="android:actionBarItemBackground">@android:color/holo_green_light</item>
<item name="android:actionMenuTextColor">@android:color/holo_green_dark</item>
</style>
</resources>
TIA!
BTW minSdk设置为14
AndroidManifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app1.app1">
<application android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
答案 0 :(得分:0)
你是否在AndroidManifest.xml文件中调用它? 我的style.xml中的示例
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/green_dark</item>
<item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/white</item>
<item name="android:textStyle">bold</item>
</style>
和menifestfile
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher1"
android:label="@string/app_name"
android:theme="@style/CustomActionBarTheme" >
<activity.....
对于实现点击监听器,您需要为此案例创建选项菜单。