我有相同的标准选项菜单,但我想将项目的背景从白色更改为黑色。我看过很多关于如何执行此操作的帖子,但这些帖子不适用于 2.3。
有谁知 Prop 有与 2.3 版兼容的自定义颜色背景的工作菜单充气器?
最佳答案
查看以下解决方案是否解决了您的问题....
AndroidMenifest.xml
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/CustomTheme">
menu/options.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/option_1" android:title="Android"/>
<item android:id="@+id/option_2" android:title="iPhone"/>
<item android:id="@+id/option_3" android:title="iPad"/>
</menu>
styles.xml
<resources>
<style name="CustomTheme" parent="android:Theme">
<!-- Panel attributes -->
<!-- <item name="android:panelBackground">@drawable/menu_bg</item> -->
<item name="android:panelFullBackground">@drawable/menu_full_bg</item>
<!-- <item name="android:panelColorBackground">#FF0000</item> -->
</style>
<!-- <drawable name="menu_bg">#DDDAAA</drawable> -->
<drawable name="menu_full_bg">#000FFF</drawable>
</resources>
StackoverflowActivity.java
public class StackoverflowActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options, menu);
return true;
}
}
关于android - 如何更改 Android 2.3 的选项菜单背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10394016/