toolbar中设置menu收起图标颜色以及popupwindow弹出位置

1、设置menu收起图标颜色,就是那三个点的图标这里写图片描述,默认的如果使用light style 就是 黑色的,如果使用 dark style 就是白色的。 
如何能够自定义颜色?

 <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <!-- 添加这一句, 即可改变图标的颜色-->
        <item name="android:textColorSecondary">#ffffff</item>
    </style>
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

2、一般情况下,点击收起menu的按钮,popwindow会覆盖在toolbar上,不美观,如何能够让popwindow在toolbar下方显示呢?

 <style name="ToolbarPopupTheme" parent="@style/ThemeOverlay.AppCompat.Dark">
        <!--<item name="android:colorBackground">#000000</item> 也可以设置背景色以及menu中的其他属性-->
        <item name="actionOverflowMenuStyle">@style/OverflowMenuStyle</item> 
    </style>

    <style name="OverflowMenuStyle" parent="Widget.AppCompat.Light.PopupMenu.Overflow">
        <item name="overlapAnchor">false</item>  <!--设置不覆盖锚点-->
    </style>
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

然后在toolbar中设置app:popupTheme

 <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?android:actionBarSize"
        android:background="?attr/colorPrimary"
        app:navigationIcon="@mipmap/back"
        app:popupTheme="@style/ToolbarPopupTheme">
</android.support.v7.widget.Toolbar>
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

效果如下 
这里写图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值