How to center action menu on toolbar

前端 未结 2 432
借酒劲吻你
借酒劲吻你 2020-12-09 23:00

I have an application with a split action bar loading an action menu.

I changed the actionbar for the new toolbar and replaced the split actionbar by an other toolba

相关标签:
2条回答
  • 2020-12-09 23:21

    I've also been trying to find an answer to this question the past couple weeks. And the closest thing I have found takes advantage of the fact that the Toolbar is just a ViewGroup. All you need to do is create a menu_items layout that is just a LinearLayout with equally weighted menu items added. I know this isn't an ideal solution but I haven't found anyway to spread out the items while using the default menu.

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar_btm"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:minHeight="?attr/actionBarSize"
            android:background="@color/toolbar_bkgnd"
            android:layout_alignParentBottom="true"
            app:theme="@style/ThemeOverlay.AppCompat.ActionBar" >
    
            <include layout="@layout/menu_items"/>
    
            </android.support.v7.widget.Toolbar>
    
    0 讨论(0)
  • 2020-12-09 23:34

    In this case, Chris Banes recommends to use ActionMenuView instead of Toolbar (see the link below, reply #6). Besides that, in this link you can find a solution where the guy subclassed Toolbar in order to the split works right.

    https://code.google.com/p/android/issues/detail?id=77632#c2

    Hope it helps you!

    0 讨论(0)
提交回复
热议问题