您的位置:首页 > 移动开发 > Android开发

android toolbar 假标题居中

2016-02-18 21:06 471 查看
<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、
Call
getSupportActionBar().setDisplayShowTitleEnabled(false);`
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: