1. 程式人生 > >Toolbar menu 分割線設定

Toolbar menu 分割線設定

使用Toolbar,顯示分割線

Step1 定義Style

<style name="AppToolbarPopupTheme" parent="Widget.AppCompat.PopupMenu.Overflow">
    <item name="android:dropDownListViewStyle">@style/AppDropDownListViewStyle</item>
</style>

<style name="AppDropDownListViewStyle" parent="Widget.AppCompat.ListView.DropDown"
> <item name="android:showDividers">middle</item> <item name="android:divider">@drawable/line_divider</item> <item name="android:dividerHeight">1dp</item> </style>

Step2 在toolbar上使用定義好的style

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" app:popupTheme="@style/AppToolbarPopupTheme"> </android.support.v7.widget.Toolbar>