【发布时间】:2017-05-09 20:06:55
【问题描述】:
我正在尝试从这里设置自定义工具栏标题: Android toolbar center title and custom font
但标题仍然如下图所示:
这里是工具栏 XML:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
<TextView
android:id="@+id/toolbar_title"
android:textColor="#FFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_gravity="center" />
</android.support.v7.widget.Toolbar>
JAVA:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
TextView mTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
/*Start Font Face*/
Typeface tf = Typeface.createFromAsset(getAssets(), "Limelight.ttf");
mTitle.setTypeface(tf);
/*Rnd Font Face */
setSupportActionBar(toolbar);
mTitle.setText(toolbar.getTitle());
【问题讨论】:
标签: android xml toolbar titlebar