collapsing toolbar中去掉标题
来源:互联网 发布:李昌钰 辛普森 知乎 编辑:程序博客网 时间:2024/06/14 11:17
Materail Design中通过CollapsingToolbarLayout+Toolbar实现的Collapse的效果简直酷炫,可以是颜色,也可以是图像。当是图像的时候,问题来,Toolbar的标题会在图像上面,看起来怪怪的;有的人会说了,那你不设置标题就是了,可是Collapse回归的时候没有标题,也是怪怪的。
解决方案:Toolbar可以当做ViewGroup来使用,也就是说如下的写法是可以的
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:minHeight="?attr/actionBarSize" android:layout_width="match_parent" android:layout_height="wrap_content" app:titleTextColor="@android:color/white" android:background="?attr/colorPrimary"> <TextView
android:id="@+id/toolbarText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toolbar Title" android:textColor="@android:color/white" style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" android:layout_gravity="center" /></android.support.v7.widget.Toolbar>
效果如下:
通过
toolbarText=(TextView)toolbar.findViewById(R.id.toolbarText)就可以操作对应的文字。
基本思路有了,现在可以通过设置字体的颜色来设置Toolbar的标题了,当设置成透明颜色的时候,就看不到文字了。
RecyclerView rcyView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { int scrollingOffset = dy; if (scrollingOffset > 0) { toolbarText.setTextColor(Color.WHITE); } else if (scrollingOffset < 0) { toolbarText.setTextColor(Color.TRANSPARENT); } } });
以上代码实现的是,当Toolbar处于Collapsing的状态下,Toolbar的title不显示,而不是处于Collapsing的状态下,Toolbar的title显示。
大神带你飞:http://stay4it.com/
0 0
- collapsing toolbar中去掉标题
- Android中去掉标题的方法总结
- Android中去掉显示标题的方法
- 去掉标题
- 如何去掉toolbar阴影
- toolbar去掉阴影
- Android 去掉toolbar阴影
- Toolbar 标题居中
- toolbar标题居中
- 设置toolbar标题居中
- Toolbar设置标题居中
- toolbar标题设置居中
- toolbar标题颜色更改
- ToolBar去掉左侧默认间距
- android Toolbar去掉左右边界
- 去掉Toolbar的阴影效果
- word2010中如何去掉标题前面的小黑点
- word2010中如何去掉标题前面的小黑点
- linux 个人学习笔记(没有干货)
- 将字典里的的Null转为空
- __main__.py 和 __init__.py
- MySQL5.7解压版本安装步骤
- 基于Docker和Mesos的服务可靠性保障实践
- collapsing toolbar中去掉标题
- 逆向思维:如何判断一套JS框架不符合实际需求?
- See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
- Apache Hadoop YARN架构简介
- Ibus和Fcitx安装
- iOS开发之runtime运行时机制(一)
- std::stringstream 用法
- python 七种邮件内容发送方法实例
- Volley 传递头部Heards需要注意问题