toolbar = (Toolbar) findViewById(R.id.gen_toolbar_pln);
setSupportActionBar(toolbar);
toolbar.setTitle(R.string.title_General);
我在java中设置了工具栏的标题。它设置在左角,但我需要使这个中心。
我怎样才能制作这个标题中心?
任何帮助,将不胜感激。
您必须将 textview 作为子项添加到工具栏
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark">
<TextView
android:id="@+id/title_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_horizontal" />
</android.support.v7.widget.Toolbar>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句