修改Toolbar菜单按钮的颜色、图片、位置

1、修改三点菜单的颜色

   <style name="ToolBarTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorButtonNormal">@android:color/black</item>
        <item name="colorControlNormal">@android:color/black</item>
    </style>

2、修改三点菜单的图片

  <style name="ToolBarTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="actionOverflowButtonStyle">@style/OverFlowButton</item>
  </style>
  <style name="OverFlowButton" parent="Widget.AppCompat.ActionButton.Overflow">
        <item name="android:src">@drawable/ic_menu</item>
    </style>

3、修改菜单的弹出位置

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
        <item name="actionOverflowMenuStyle">@style/OverflowMenuStyle</item>
</style>
<style name="OverflowMenuStyle" parent="@style/Widget.AppCompat.PopupMenu.Overflow">
        <!-- 修改竖直方向上与屏幕顶端的距离为50dp -->
        <item name="android:dropDownVerticalOffset">50dp</item>
        <!-- 修改水平方向上与屏幕右端的距离为10dp -->
        <item name="android:dropDownHorizontalOffset">10dp</item>
 </style>

4、最后在toolbar中引用theme

 <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:fitsSystemWindows="true"
            app:theme="@style/ToolBarTheme"
            app:popupTheme="@style/AppTheme.PopupOverlay">       
 </android.support.v7.widget.Toolbar>



  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值