0

我想将标题放在操作栏中。我已经创建了一个自定义布局,如果主页图标可见,它确实会出现在中心,但如果将其设置为 false,那么标题会向左移动,因此不会出现在中心。

操作栏应该只有标题和菜单选项,没有主页图标,可以让用户回到上一个屏幕。我什至尝试给它留出余量,但它仍然不起作用。

有什么解决方法吗?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
    android:id="@+id/txtTitle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:ellipsize="end"
    android:maxLines="1"
    android:text="@string/app_name"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@android:color/white"
    android:textSize="@dimen/title_size" />

</RelativeLayout>
4

0 回答 0