码迷,mamicode.com
首页 > 移动开发 > 详细

android toolbar 假标题居中

时间:2016-02-18 21:36:30      阅读:460      评论:0      收藏:0      [点我收藏+]

标签:

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_top"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Toolbar Title"
android:layout_gravity="center"
android:id="@+id/toolbar_title" />


</android.support.v7.widget.Toolbar>

This means that you can style the TextView however you would like because it’s just a regular TextView. So in your activity you can access the title like so:

Toolbar toolbarTop = (Toolbar) findViewById(R.id.toolbar_top);
TextView mTitle = (TextView) toolbarTop.findViewById(R.id.toolbar_title);
  • 1
  • 2

If anyone else can’t remove the default app name title, do this:

1、Call setSupportActionBar(yourToolbar) 
2、CallgetSupportActionBar().setDisplayShowTitleEnabled(false);`

android toolbar 假标题居中

标签:

原文地址:http://www.cnblogs.com/gisoracle/p/5199303.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!