我需要更改PopMenu(设置)的颜色。我更新了style.xml但没有工作。然后尝试改变Item的颜色,也没有用。 我需要一点灰色背景和白色TextColor。
MyActivity.java扩展了ActionBarActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
MenuItem item = menu.findItem(R.id.file);
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
mShareActionProvider.setOnShareTargetSelectedListener(this);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
openShare();
return false;
}
});
return true;
}
MyActivity_layout.xml
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/action_bar_background"
app:theme="@style/ToolbarTheme"
app:popupTheme="@style/Theme.AppCompat"
>
main.xml中(菜单)
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.app.MyActivity">
<item android:id="@+id/file"
android:title="Setting"
android:icon="@drawable/ic_setting"
app:actionProviderClass=
"android.support.v7.widget.ShareActionProvider">
</item>
</menu>
styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="android:popupBackground">@android:color/white</item>
</style>
<style name="AppTheme" parent="AppTheme.Base">
</style>
<style name="ToolbarTheme" parent="Theme.AppCompat">
<item name="android:windowNoTitle">true</item>
<item name="android:textColorPrimary">@color/action_bar_text</item>
<item name="actionMenuTextColor">@color/action_bar_text</item>
<item name="android:textColorSecondary">@color/action_bar_text</item>
<item name="android:layout_gravity">center_horizontal</item>
</style>
</resources>
的Manifest.xml
<application
android:allowBackup="true"
android:icon="@mipmap/ic_app"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
...
</application>
答案 0 :(得分:0)
没关系,我刚刚更新了:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/action_bar_background"
app:theme="@style/AppTheme"
app:popupTheme="@style/AppTheme"
>