我正在测试新的Appcompat 21 Material Design功能.因此我创建了一个这样的工具栏:
<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/activity_my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"/>
Run Code Online (Sandbox Code Playgroud)
并将其包含在我的主布局文件中.
然后我将它设置为supportActionBar:
Toolbar toolBar = (Toolbar)findViewById(R.id.activity_my_toolbar);
setSupportActionBar(toolBar);
Run Code Online (Sandbox Code Playgroud)
它工作,但不知何故,我无法弄清楚如何自定义工具栏.它是灰色的,上面的文字是黑色的.我该如何更改背景和文字颜色?
我已经完成了这个指示:
http://android-developers.blogspot.de/2014/10/appcompat-v21-material-design-for-pre.html
我有什么要改变颜色的?
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:windowActionBar" tools:ignore="NewApi">false</item>
<item name="windowActionBar">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
编辑:
我可以通过在主题中添加以下代码行来更改背景颜色:
<item name="colorPrimary">@color/actionbar</item>
<item name="colorPrimaryDark">@color/actionbar_dark</item>
Run Code Online (Sandbox Code Playgroud)
但它们不会影响文字颜色.我错过了什么?我宁愿选择白色文字和白色菜单按钮,而不是黑色文字和黑色菜单按钮:

android android-appcompat android-actionbar android-actionbar-compat android-toolbar
我想更改Android 4.2中选项(溢出)菜单的背景颜色.我已经尝试了所有方法,但它仍然显示主题设置的默认颜色.我使用了以下代码和XML配置.
MainActivity.java
public class MainActivity extends Activity {
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getActionBar().setIcon(R.drawable.ic_launcher);
getActionBar().setTitle("Sample Menu");
getActionBar().setBackgroundDrawable(new
ColorDrawable(Color.parseColor("#33B5E5")));
int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
TextView titleText = (TextView)findViewById(titleId);
titleText.setTextColor(Color.parseColor("#ffffff"));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
setMenuBackground();
return true;
}
protected void setMenuBackground(){
// Log.d(TAG, "Enterting setMenuBackGround");
getLayoutInflater().setFactory( new Factory() {
@Override
public View onCreateView(String name, Context context, …Run Code Online (Sandbox Code Playgroud) android android-menu android-theme android-actionbar android-4.2-jelly-bean
我正在为Android 5.0准备我的应用程序,我正在使用最新的兼容性库,这是我的样式.
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/theme_accent</item>
<item name="colorAccent">@color/theme_accent_secondary</item>
</style>
<style name="AppThemeDark" parent="Theme.AppCompat">
<item name="colorPrimary">@color/theme_accent</item>
<item name="colorAccent">@color/theme_accent_secondary</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
(正在以编程方式设置ActionBar颜色.)
现在,我希望溢出/弹出菜单具有类似于holo实现中的深色背景,但我无法使其工作,这是它的样子: 
我试过设置popupMenuStyle但它没有用.
如何让弹出菜单变暗?
android android-ui android-support-library material-design android-5.0-lollipop
出于某种原因,在我的应用程序中,当使用"Theme.AppCompat"作为我的样式时,它使我的菜单黑色文本(我设置,因为我想要黑色文本)在深灰色背景上,如下所示:

我尝试使用一些在线资源手动设置菜单的背景颜色,但似乎没有工作.有谁知道可能导致这个问题的原因?下面是我的style.xml,正如您所看到的,主应用主题条目中的两个底部元素是我尝试使用我在网上找到的东西来改变背景颜色.
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<item name="windowActionBar">false</item>
<item name="android:windowBackground">@color/white_primary</item>
<item name="android:textColor">@color/text_primary</item>
<item name="android:textSize">@dimen/text_size_medium</item>
<item name="colorAccent">@color/black_primary</item>
<item name="android:popupMenuStyle">@style/PopupMenuStyle</item>
<item name="android:panelFullBackground">@drawable/menu_full_bg</item>
</style>
<style name="PopupMenuStyle" parent="Theme.AppCompat.Light">
<item name="android:popupBackground">@android:color/white</item>
</style>
<drawable name="menu_full_bg">#FFFFFF</drawable>
Run Code Online (Sandbox Code Playgroud)
xml android colors android-actionbar android-actionbar-compat
我正在使用android紧凑库为android和更新版本构建操作栏.所以我的要求包括我需要显示蓝色的动作栏.现在我已将操作栏背景颜色更改为蓝色,现在我想更改弹出菜单的背景颜色,当我们点击溢出图标时.我试过很多方面,但没有什么改变背景颜色.没有人建议我是否可以使用app-compact库更改弹出菜单的背景颜色,如果我们可以请建议我