Android align menu items to left in action bar

前端 未结 2 1149
暗喜
暗喜 2021-02-07 10:30

i have action bar in my application that displays menu items defined in my res/menu/activity_main.xml

My menu items are aligned to right on action bar. I wa

2条回答
  •  逝去的感伤
    2021-02-07 10:54

    You can do it like this:

    activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
                ActionBar.DISPLAY_SHOW_CUSTOM);
    activity.getActionBar().setCustomView(mAutoSyncSwitch, new ActionBar.LayoutParams(
                ActionBar.LayoutParams.WRAP_CONTENT,
                ActionBar.LayoutParams.WRAP_CONTENT,
                Gravity.CENTER_VERTICAL | Gravity.LEFT));
    

提交回复
热议问题