【问题标题】:android: how to change Text size, color of Options Menu Items and options menu height and widthandroid:如何更改文本大小、选项菜单项的颜色以及选项菜单的高度和宽度
【发布时间】:2019-03-02 04:01:50
【问题描述】:

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

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;
    }
});

现在我必须自定义菜单大小、文本大小/颜色。任何人请帮助我。

提前致谢。

【问题讨论】:

  • 我投票结束这个问题,因为它已经过时了。选项菜单是由早于 Android 4 的平台上的硬件菜单键触发的。当代等效项是 ActionBar 弹出菜单。

标签: android options-menu


【解决方案1】:

【讨论】:

    【解决方案2】:

    Width , Heigth 你需要 hack 操作栏。

    但如果您需要自定义,请使用:ActionBarGenerator (http://jgilfelt.github.io/android-actionbarstylegenerator/)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-23
      • 1970-01-01
      • 1970-01-01
      • 2015-09-11
      • 1970-01-01
      • 1970-01-01
      • 2011-04-14
      • 1970-01-01
      相关资源
      最近更新 更多