android:如何更改文本大小,选项菜单项的颜色和选项菜单的高度和宽度

时间:2011-02-22 11:02:45

标签: android options-menu

我已使用以下代码成功自定义选项菜单的背景。

getLayoutInflater().setFactory(new Factory() {
    @Override
    public View onCreateView(String name, Context context, AttributeSet attrs) {
        if (name.equalsIgnoreCase("com.android.internal.view.menu.IconMenuItemView")) {
            try { // Ask our inflater to create the view
                LayoutInflater f = getLayoutInflater();
                final View view = f.createView(name, null, attrs);
                /*
                 * The background gets refreshed each time a new item is
                 * added the options menu. So each time Android applies
                 * the default background we need to set our own
                 * background. This is done using a thread giving the
                 * background change as runnable object
                 */
                new Handler().post(new Runnable() {
                    public void run() {
                        view.setBackgroundResource(R.drawable.blue_bg_pixel);
                    }
                });
                return view;
            }
            catch (InflateException e) {
            }
            catch (ClassNotFoundException e) {
            }
        }
        return null;
    }
});

现在我必须自定义菜单大小,文字大小/颜色。任何人都可以帮助我。

提前致谢。

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

宽度,高度你需要黑客行动吧。

但是如果你需要自定义,请使用:ActionBar Generator({{3p>

相关问题