如何将导航抽屉应用程序的标题居中? [英] How can I center the title of navigation drawer application?

查看:81
本文介绍了如何将导航抽屉应用程序的标题居中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改导航抽屉应用程序(Android Studio)的标题位置?

How can I change the title position of navigation drawer application (Android studio)?

推荐答案

在工具栏内用gravity = "center"插入了文本视图,并通过Java禁用了默认标题.

Here inside Toolbar inserted a textview with gravity = "center" and disable default title by java.

尝试以下代码:

<android.support.design.widget.AppBarLayout
        app:elevation="0dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <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:layout_width="wrap_content"
            android:textSize="18dp"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="Title Here"
            android:textColor="@color/white" />

        </android.support.v7.widget.Toolbar>

    </android.support.design.widget.AppBarLayout>

java代码禁用您的标题:

java code disable your title :

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

这篇关于如何将导航抽屉应用程序的标题居中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆