背景涟漪效应在独立工具栏项目是走了 [英] Background Ripple Effect on StandAlone Toolbar items is gone

查看:204
本文介绍了背景涟漪效应在独立工具栏项目是走了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用独立的工具栏上有一个问题的项目选择能力的背景下,下面的这篇文章也没工作:

Using the Standalone toolbar has an issue with the select able background of the items, following this article didn't work also:

http://blog.mohitkanwal.com/blog/2015/03/07/styling-material-toolbar-in-android/

使用独立的工具栏时,检查正常的工具栏下面的截图,产生的连锁反应选择走了。

Check the normal toolbar in the below screenshot, the ripple effect selector is gone when using the standalone toolbar.

这是我的风格:

 <style name="ToolbarTheme" parent="Widget.AppCompat.Toolbar">
        <item name="actionMenuTextColor">@color/green</item>
        <item name="drawerArrowStyle">@style/DrawerArrowToggle</item>
        <item name="colorControlNormal">@color/white</item>
        <item name="colorControlActivated">@color/white</item>
        <item name="android:textColorPrimary">@color/white</item>
        <item name="titleTextAppearance">@style/ActionBar.TitleText</item>
        <item name="android:actionOverflowButtonStyle">@style/MoreActionButton</item>
        <item name="actionButtonStyle">@style/Widget.AppCompat.ActionButton</item>
        <item name="selectableItemBackground">?android:selectableItemBackground</item>
        <item name="selectableItemBackgroundBorderless">?android:selectableItemBackground</item>
        <item name="colorControlHighlight">@color/accentColor</item>
    </style>

编辑: 从我的code分离的问题后,我能够重现问题,现在看来,这是关系到新的支撑设计库。这里是考验code,有问题的:

After isolating the issue from my code I was able to reproduce the issue and it seems it is related to the new support design library. And here is the test code that has the issue:

TestToolbar.zip

推荐答案

这是采用了android 5.1 genymotion模拟器完成

This was done using android 5.1 genymotion emulator

我没弄明白你的问题,但我只是想创建一个工具栏和你的一样,但去掉了一些风格,我没有

I didn't figure out your problem, but I just tried to create a toolbar the same as yours, but with removing some style that I don't have

这是我的风格。

  <style name="ToolbarTheme"
      parent="Widget.AppCompat.Toolbar">
    <item name="actionMenuTextColor">#1bff3a</item>
    <item name="colorControlNormal">#FFF</item>
    <item name="colorControlActivated">#FFF</item>
    <item name="android:textColorPrimary">#FFF</item>
    <item name="actionButtonStyle">@style/Widget.AppCompat.ActionButton</item>
    <item name="selectableItemBackground">?android:selectableItemBackground</item>
    <item name="selectableItemBackgroundBorderless">?android:selectableItemBackground</item>
    <item name="colorControlHighlight">@color/accentColor</item>
  </style>


我的工具栏布局


My Toolbar layout

 <android.support.v7.widget.Toolbar
      android:id="@+id/toolbar"
      android:layout_width="match_parent"
      android:layout_height="?attr/actionBarSize"
      android:background="?colorPrimary"
      app:theme="@style/ToolbarTheme"
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
      />


我的菜单


My Menu

<item
      android:id="@+id/action_settings"
      android:title="@string/action_settings"
      android:icon="@drawable/abc_ic_clear_mtrl_alpha"
      app:showAsAction="always"
      />


活动code


The activity code

   Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
   toolbar.inflateMenu(R.menu.menu_home);


结果的截图


Screenshot of the result

修改

下载您的问题提供的样品后,这个问题已经没有任何关系的独立工具栏或动作条(两者有相同的问题)时,使用 AppBarLayout ,问题看来,纹波效应将在 AppBarLayout 绘制,而不是选择的菜单项的看法,我会记录视频解释它。

after downloading the sample you provided in the question, the problem has nothing to do with standalone toolbar or actionbar (both have the same problem) when using AppBarLayout, the problem seems that the Ripple effect will be drawn on AppBarLayout instead of the View of the selected menu item, I'll record a video explaining it.

视频: AppBarLayout与工具栏视频

我会尽力找到一个解决方案。

I'll try to find a solution for this.

这篇关于背景涟漪效应在独立工具栏项目是走了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆