昨天一直在琢磨为什么Toolbar和CollapsingToolbarLayout一起使用时menu item无点击放应的原因,后来在stackoverflow上一条回答,说可能是Toolbar的背景颜色太深导致点击时的水波纹不明显。这个启发了我,会不会是跟toolbar的背景有关呢?贴上代码:

  

<android.support.design.widget.CoordinatorLayout 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"
android:fitsSystemWindows="false"
android:orientation="vertical"> <android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:fitsSystemWindows="false"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp"> <android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed"> <ImageView
         android:layout_width="match_parent"
                android:layout_height="48dp"/> <android.support.v7.widget.Toolbar
android:id="@+id/home_page_toolbar"
android:layout_width="match_parent"
android:layout_height="48dp" android:minHeight="44dp"
app:layout_collapseMode="pin"
app:navigationIcon="@mipmap/nav_menu"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> <TextView
android:id="@+id/home_page_toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:text="首页"
android:textColor="@color/white"
android:textSize="@dimen/textsize_zhuche" /> </android.support.v7.widget.Toolbar> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"> <android.support.design.widget.TabLayout
android:id="@+id/tab_FindFragment_title"
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="@color/homepage_toolbar_color"
android:elevation="@dimen/tablayout_elevation"
app:tabIndicatorColor="@color/white"
app:tabIndicatorHeight="@dimen/tabindicatorheight"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/white"
app:tabTextAppearance="@style/tabLayoutTextSize"
app:tabTextColor="#F8BBD0" /> <android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"> <android.support.v4.view.ViewPager
android:id="@+id/homepage_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" /> </android.support.v4.widget.SwipeRefreshLayout> </LinearLayout> </android.support.design.widget.CoordinatorLayout>

发现果然toolbar没有设置背景,于是设置

android:background="@color/red"
果然toolbar上的memu item有点击反馈了有木有! 可是这样Toolbar就会永远占据一行的位置,我想要的是CollapsingToolbarLayout扩展的时候toolbar变得透明,像这样
解决办法是toolbar的背景设置成透明色,
android:background="@color/transprant"
这样就既能有点击反馈,又能实现上面的效果。
运行效果:

 

Toolbar 和 CollapsingToolbarLayout一起使用时menu item无点击反应解决办法的更多相关文章

  1. ListView中的Item不能点击的解决方法

    有时,为了实现某种功能,在Android程序中会考虑在ListView的每一个Item中添加一个Button(或ImageButton等). 但是,这样会出现一个问题: 当同时设置了Button的on ...

  2. SpringBoot框架:两个方法同时调用时父方法使内部方法的DataSource注解失效的解决办法

    一.问题如下: 使用的是SpringBoot框架:通过AOP和自定义注解完成druid连接池的动态数据源切换(三)中的两个数据库spring_boot_demo和other_data. 在UserCo ...

  3. Android自定义ListView的Item无法响应OnItemClick的解决办法

     转: 如果你的自定义ListViewItem中有Button或者Checkable的子类控件的话,那么默认focus是交给了子控件,而ListView的Item能被选中的基础是它能获取Focus,也 ...

  4. Android自定义ListView的Item无法响应OnItemClick的解决办法(转)

    原文链接:http://www.linuxidc.com/Linux/2011-09/43205.htm 如果你的自定义ListViewItem中有Button或者Checkable的子类控件的话,那 ...

  5. ubuntu16.04登录后无dash,无启动栏launch,无menu bar,只有桌面背景解决办法

    今天打开电脑,与往常一样输入用户名密码登录后,发现桌面上空空如也,启动栏launch,menu bar什么的都消失了,桌面上文件可以打开,但是无法拖动位置,无法关闭(因为menu bar没了,无法鼠标 ...

  6. 网易MuMu模拟器不显示Menu(菜单)键的解决办法

    解决方法一: 前提:需要一个键盘 步骤: 1.直接按下键盘上的Menu键. 解决方法二: 前提:需要Root之后的文件浏览器 步骤: 1.在文件管理器中打开 /System 文件夹: 2.复制 bui ...

  7. 关于vs2013error C4996: 'strcmpi': The POSIX name for this item is deprecated.的错误解决办法!

    1.出现如下错误(如图1) 2.解决办法(如图2)在头文件处添加#pragma warning(disable: 4996)

  8. Alamofire使用报错Extra argument 'method' in call解决办法

    使用Alamofire的时候,在用这句的时候报错了: Extra argument 'method' in call Alamofire.request("", method: H ...

  9. eclilpse svn : Item is out of date 解决办法

    尝试以下方面, 1. 2.如果上面的还不行,就说明你修改了原有项目结构,可能是增加了新包,或者重命名的包或文件,那么你得先update,然后再提交 这样就OK了,我就是用了2才成功的哦.

随机推荐

  1. Linux下MySql启动时报错

    /opt/mysql/support-files/mysql.server startmy_print_defaults: [ERROR] Found option without preceding ...

  2. Objective-C中的单例模式(工具类)

    单例是iOS开发中经常会用到的一种设计模式,顾名思义,即创建一个类,该类在整个程序的生命周期中只有一个实例对象,无论是通过new,alloc init,copy等方法创建,或者创建多少个对象,自始至终 ...

  3. 图片自动转换效果 jquery

    http://www.16sucai.com/uploadfile/show5/switchable01/switchable/ <div class="maxpSlid" ...

  4. 文件:因为懂你,所以永恒 - 零基础入门学习Python028

    文件:因为懂你,所以永恒 让编程改变世界 Change the world by program 因为懂你,所以永恒 大多数的程序都遵循着:输入->处理->输出的模型,首先接受输入数据,然 ...

  5. 自定义ListView分割线

    要完成自定义分割线,我们先来认识一下listview中的两个属性: android:divider 设置list 列表项的分隔条(可用颜色分隔,也可用Drawable分隔) android:divid ...

  6. format %x invalid or incompatible with argument问题解决方法

    现在还有好多朋友在用Protel 99se来画图,可是在现在的双核或四核电脑上运行Protel出现错误并且弹出对话框:“format '%x' invalid or incompatible with ...

  7. Intent.ACTION_TIME_TICK 广播

    Intent.ACTION_TIME_TICK 广播需要动态注册,不能在清单文件配置. TimeReceiver mBroadcastReceiver = new TimeReceiver(); In ...

  8. [Android开发常见问题-18] Connection to https://dl-ssl.google.com refused

    在使用Android SDK Manager的时候,有时候会遇到上述问题,其实原因很简单,属于本地配置的问题. 解决方法: 1.以文本文件的方式打开“C:\Windows\System32\drive ...

  9. unix c 05

    dup和dup2用于复制文件描述符,区别在于dup2可以指定新的文件描述符的数值,如果新的文件描述符的值已经被使用,dup2会关闭掉后进行复制. dup和dup2 不会复制文件表,只是文件描述符的复制 ...

  10. IT人员应该怎么跳槽

    中国的程序员只有两个状态,刚跳槽和准备跳槽.   中国IT行业的快速发展对IT从业人员的需求不断扩大,记得08年刚毕业的时候,在帝都找一个3k的工作都让我特别满足,现在仅能写出”hello world ...