reference to : http://blog.csdn.net/elder_sword/article/details/46634751

Toolbar是什么,不知道的可以去大神的博客瞻仰下
http://blog.csdn.net/lmj623565791/article/details/45303349
我当时也是看这篇学习的,但是怎么说,看完之后想在自己的项目中把Toolbar完全自定义的时候,博客中并没有讲解。这篇博客也只是一个记载,并没有很高深的技术,废话不多说。

我自己项目中的样子

下面的布局里你就可以随便写你的Toolbar了。注意下面在设置title等属性的时候要用app命名空间,android打头的也有,但是可能设置不会显示
toolbar.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:segmentedgroup="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:navigationIcon="@drawable/press_back"
app:title=" " >
<TextView
android:id="@+id/toolbar_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="16dp"
android:text="num"
android:textColor="#fff"
android:visibility="gone"
android:textSize="16dp" />
<com.hs.diskmanager.view.SegmentedGroup
android:id="@+id/toolbar_segment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:orientation="horizontal"
segmentedgroup:border_width="1dp"
segmentedgroup:checked_text_color="#ff33b5e5"
segmentedgroup:corner_radius="10dp"
segmentedgroup:tint_color="@android:color/white" > <RadioButton
android:id="@+id/toolbar_phone"
style="@style/RadioButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="One" /> <RadioButton
android:id="@+id/toolbar_udisk"
style="@style/RadioButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Two" />
</com.hs.diskmanager.view.SegmentedGroup> <TextView
android:id="@+id/toolbar_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="16dp"
android:text="编辑"
android:textColor="#fff"
android:textSize="16dp" /> </android.support.v7.widget.Toolbar>

对应布局引用

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" > <include layout="@layout/toolbar" android:id="@+id/id_toolbar"/>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/id_toolbar">
</FrameLayout>
</RelativeLayout>

可能有点人用完会发现自己下面的布局盖在Toolbar的布局上了,解决方法上面也有写到,就是below,其它不再多说.

[Android Pro] Toolbar的完全自定义的更多相关文章

  1. Android线程管理之ThreadPoolExecutor自定义线程池

    前言: 上篇主要介绍了使用线程池的好处以及ExecutorService接口,然后学习了通过Executors工厂类生成满足不同需求的简单线程池,但是有时候我们需要相对复杂的线程池的时候就需要我们自己 ...

  2. Android下添加新的自定义键值和按键处理流程

            Android下添加新的自定义键值和按键处理流程     说出来不怕大家笑话,我写这篇博客的原因在于前几天去一个小公司面试Android系统工程师,然后在面试的时候对方的技术总监问了我 ...

  3. android:ToolBar详解

    android:ToolBar详解(手把手教程) 泡在网上的日子 发表于 2014-11-18 12:49 第 124857 次阅读 ToolBar 42 来源 http://blog.mosil.b ...

  4. Android中使用ListView绘制自定义表格(2)

    上回再写了<Android中使用ListView绘制自定义表格>后,很多人留言代码不全和没有数据样例.但因为项目原因,没法把源码全部贴上来.近两天,抽空简化了一下,做了一个例子. 效果图如 ...

  5. 【Android Training UI】创建自定义Views(Lesson 1 - 创建一个View类)

    发布在我的网站 http://kesenhoo.github.io/blog/2013/06/30/android-training-ui-creating-custom-views-lesson-1 ...

  6. Android图表库MPAndroidChart(五)——自定义MarkerView实现选中高亮

    Android图表库MPAndroidChart(五)--自定义MarkerView实现选中高亮 在学习本课程之前我建议先把我之前的博客看完,这样对整体的流程有一个大致的了解 Android图表库MP ...

  7. 强烈推荐:Android史上最强大的自定义任务软件Tasker

    强烈推荐:Android史上最强大的自定义任务软件Taskerhttp://bbs.mumayi.com/thread-28387-1-1.html(出处: 木蚂蚁手机乐园) Android上的Tas ...

  8. Android调用系统相机、自定义相机、处理大图片

    Android调用系统相机和自定义相机实例 本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显示出来,该例子也会涉及到Android加载大图片时候的处理 ...

  9. Android下添加新的自定义键值和按键处理流程【转】

    本文转载自: Android下添加新的自定义键值和按键处理流程     说出来不怕大家笑话,我写这篇博客的原因在于前几天去一个小公司面试Android系统工程师,然后在面试的时候对方的技术总监问了我一 ...

随机推荐

  1. 【C语言入门教程】7.3 结构体指针的定义和引用

    C 语言中指针的操作非常灵活,它也能指向结构体变量对结构体变量进行操作.在学习结构指针之前,需要再次加深对指针的认识.声明指针变量时所使用的数据类型修饰符实际上的作用是定义指针访问内存的范围,如果指针 ...

  2. Linux下安装和配置JDK与Tomcat(入门版)

    JDK路径:/usr/java/jdk1.6.0_25 Tomcat路径:/usr/local/apache-tomcat 1. 下载jdk6.0(选择“.rpm.bin”结尾的,6u25版本) ht ...

  3. ASN.1编码

    来自几年前本人写的一篇博客 http://blog.csdn.net/newyf_cun/article/details/13016069 如下使用libtasn1分析asn1的编码规则. http: ...

  4. oracle 彻底删除用户及表空间

    1.删除表空间 可以先将其offline alter tablespace xxx offline; 将磁盘上的数据文件一同删除 drop tablespace xxx including conte ...

  5. 4. Linux常用命令

    1. ls  查看当前目录信息 2. pwd 查看当前目录 3. cd 切换目录  快捷操作:cd - 可快速对最近的两个目录切换, cd 或者cd~ 直接回到用户自己的主目录, 4. hwclock ...

  6. 推荐ubuntu下的画图工具

    今天发现ubuntu下面也有类似于windows画图的画图工具,功能也比较强大,支持各种格式的图片,也有各种工具,非常方便,安装的方法是: sudo apt-get install kolourpai ...

  7. leetcode 33. Search in Rotated Sorted Array

    Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 migh ...

  8. ORA-02287: 此处不允许序号

    今天使用 insert into select 时出现了这个异常,感觉很诡异,去metalink查了下资料,找出了错误原因,记录下来. SQL> CREATE TABLE test_baser0 ...

  9. [转载]Linux下tomcat的catalina.out文件过大,以及目录更改解决办法

    原文链接:http://liyan0524.iteye.com/blog/1285644 方法1—分割流 使用cronolog工具切分Tomcat的catalina.out日志文件 cronolog一 ...

  10. u-boot 2011.09 开启debug 调试

    以前做过,现在刚才又想不起来了,这个错误非常的严重. 在这里记一下. debug 调试信息的开启在 include/common.h 有如下宏定义: #ifdef DEBUG #define debu ...