(笔记)Android使用ToolBar
来源:互联网 发布:哪个网络好用 编辑:程序博客网 时间:2024/06/07 14:34
布局文件:activity_main.xml的布局中加入:
<android.support.v7.widget.Toolbar android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/toolbar" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="zuo" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="中间" /> <android.support.v7.widget.AppCompatImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_launcher" android:layout_marginRight="16dp" android:layout_gravity="right" /> </android.support.v7.widget.Toolbar>
mainActivity的onCreate()方法中加入:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);setSupportActionBar(toolbar);
接下来设置事件监听器什么的就可以了。
1、在ToolBar中的组件,例如第三个AppCompatImageButton,设置位置时,没有提示layout_gravity,但是可以设置有效。(IDE是Android Studio2.2.2)
2、xml文件中“<”是需要转义的,即使是在双引号里也要转义。("&","<",">"分别需要写成"&","<",">")
参考:
http://blog.csdn.net/fjekin/article/details/52262863
http://jaenson.iteye.com/blog/945469
阅读全文
0 0
- (笔记)Android使用ToolBar
- Android笔记:ToolBar和SearchView使用
- Android-ToolBar学习笔记
- toolbar使用笔记
- toolbar使用笔记
- ToolBar使用笔记
- Android-Toolbar 使用
- Android --Toolbar的使用
- android Toolbar使用
- android toolbar的使用
- Android Fragment使用Toolbar
- Android ToolBar 基本使用
- [Android]ToolBar使用心得
- Android Toolbar使用ActionMode
- Android:ToolBar使用
- Android Toolbar 使用
- Android ToolBar使用
- Android Toolbar使用ActionMode
- 《React-Native系列》16、 RN组件之ListView
- MaterialDialogs源码解析(二)
- 文件上传完整实例(限制格式、大小)
- github如何将已有的项目转移到组织仓库中去
- mysql使用汇总
- (笔记)Android使用ToolBar
- rtmpdump 能用RTMP_SendPacket发送一帧数据包吗?
- JDBC 批量存入数据库
- IgH(IgH EtherCAT Master for Linux)编译之linux Debian篇
- java生成excel存放到web-inf
- Android 通过反射获取系统组件的私有变量,并做更改
- NP课后习题8.3
- Javascript 自动在每N个字符后面加-
- java组合模式