ToolBar居中显示文字或控件
来源:互联网 发布:网络本科有哪些学校 编辑:程序博客网 时间:2024/06/08 17:17
转载请标明出处:http://blog.csdn.net/wu_wxc/article/details/48263007
本文出自【吴孝城的CSDN博客】
想在ToolBar工具栏居中显示文字或控件其实并不难,只需要在toolbar布局里加入就行
在toolbar里,创建LinearLayout布局,设置宽度匹配父元素,内部控件居中显示,然后就可以在LinearLaout里写控件了。
<?xml version="1.0" encoding="utf-8"?><android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="match_parent" android:background="?attr/colorPrimary"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮" android:textSize="20sp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="你好" android:textSize="20sp"/> </LinearLayout></android.support.v7.widget.Toolbar>
至于ToolBar其他内容看
aterial Design 之 ToolBar
源码
1 0
- ToolBar居中显示文字或控件
- 关于Toolbar的定制--文字或图片居中
- Toolbar文字居中
- Edit控件单行显示文字垂直居中的办法
- 自定义控件文字居中
- ToolBar标题文字居中的方法
- 文字居中显示
- RaidoButton文字居中显示
- toolbar的navigationIcon不垂直居中显示
- Edit控件文字垂直居中
- Accordion头部文字居中显示
- TextView文字+drawableLeft居中显示
- 设TextView文字居中显示
- tabhost tabwidget文字居中显示
- 关于spinner文字居中显示
- Android TextView 文字居中显示
- 文本框文字居中编辑 显示
- html文字居中对齐显示
- Delphi 事件 --事件原来是函数指针,同时是个属性
- adjacent_find
- iOS KVC & KVO
- STL map的使用(二)
- SecureZeroMemory和ZeroMemory的区别
- ToolBar居中显示文字或控件
- CSS margin 属性
- 入手Cubieboard2之制作最小Linux系统
- Hibernate – One-to-One example (Annotation)
- hadoop学习之hadoop完全分布式集群安装
- nginx启用php
- ashx入门
- 清除Teleport的tppabs标签
- jsp读取properties配置文件