Android:如何将活动标签置于中心位置
我想使标签(我的应用程序)在操作栏中居中对齐。我该怎么办 以下是当前屏幕:Android:如何将活动标签置于中心位置,android,android-actionbar,label,Android,Android Actionbar,Label,我想使标签(我的应用程序)在操作栏中居中对齐。我该怎么办 以下是当前屏幕: 如果您使用的是工具栏,您可以尝试以下方法: <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?attr/actionBarSize"> <Text
如果您使用的是
工具栏
,您可以尝试以下方法:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
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="My App"
android:layout_gravity="center"
android:id="@+id/toolbar_title" />
</android.support.v7.widget.Toolbar>
而您的_布局应该如下所示:
<?xml version="1.0" encoding="utf-8"?>
您正在使用工具栏吗?您是否尝试过我的答案@Ji Ya?尝试过。它可以让标签位于中间,但不能居中。栏的右侧有一个齿轮图标,因此标签从中间偏左一点。无论如何,这个解决方案是有效的。我稍后再试。谢谢!如果我只使用活动,我应该怎么做<代码>
您在哪里使用活动?
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="myApp"
android:id="@+id/tvtitle" />