Android自学之路,ToolBar的使用标题居中颜色设置
2015-12-03 19:56
393 查看
要使用,toolbar就必须将主题设置为没有ActionBar在style文件中将Theme设置为NoAcTIONBAR
设置主副标题在Java中设置
mToolBar.setTitle(“My Title”);
mToolBar.setSubtitle(“Sub title”);
标题居中设置:
将标题设为“”
然后在layout中
好的今天的博客先写到这里,打球去了。
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> </resources> 然后再Java中写入 ` android.support.v7.widget.Toolbar mToolBar= (android.support.v7.widget.Toolbar) this.findViewById(R.id.toolbar); setSupportActionBar(mToolBar);` 设置total的颜色的方法是,在style中新建项 <style name="ToolBarTheme"> <item name="android:textColorPrimary">@color/white</item> </style>
设置主副标题在Java中设置
mToolBar.setTitle(“My Title”);
mToolBar.setSubtitle(“Sub title”);
标题居中设置:
将标题设为“”
然后在layout中
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_gravity="center" android:text="www.dastorm.com" android:textColor="@android:color/white" android:textSize="20sp" android:textStyle="bold"></TextView> </android.support.v7.widget.Toolbar>
好的今天的博客先写到这里,打球去了。
相关文章推荐
- Android手势认知
- Android学习摘记——自定义Adapter的心得
- Gradle 第六讲 之 android插件的入门1
- Android studio中添加外部的jar包
- Android自定义属性时TypedArray的使用方法
- Android中JNI开发的入门知识:一
- Android SDK 开发范例大全 ---3.11返回数据到前一个Activity
- 简单柱状图的实现
- AndroidStudio安装SVN遇到的坑爹的问题Can't use Subversion command line client
- android studio快捷键大全
- Android 常用 Style 属性
- android反编译apk常用工具
- Android 使用android-support-multidex解决Dex超出方法数的限制问题,让你的应用不再爆棚
- Android studio debug使用正式的签名
- Android PopupWindow with ListView的一些问题
- android init.rc文件语法详解(续)
- android之ContentProvider和Uri详解
- android学习5——画图问题
- 如何优化 Android Studio 启动、编译和运行速度?
- Android Studio关于SVN的相关配置简介