Android 如何以编程方式更改上下文操作栏的颜色?

Android 如何以编程方式更改上下文操作栏的颜色?,android,contextmenu,Android,Contextmenu,我需要以编程方式更改上下文操作栏的颜色。如何以我熟悉的方式做这件事。提前感谢使用代码 getActionBar().setBackgroundDrawable( <create a background drawable with solid rectangle and color as what you want>); 如果您正在使用支持库,请尝试使用 getSupportActionBar().setBackgroundDrawable(<create a

我需要以编程方式更改上下文操作栏的颜色。如何以我熟悉的方式做这件事。提前感谢

使用代码

   getActionBar().setBackgroundDrawable( <create a background drawable with solid rectangle and color as what you want>);
如果您正在使用支持库,请尝试使用

    getSupportActionBar().setBackgroundDrawable(<create a background drawable with solid rectangle and color as what you want>);

可能的重复不是针对动作模式,而是针对动作栏