[英]how to set a Title in the middle of the toolbar in Navigation Drawer?
A very little bit problem i will be thankful to you if you will help me, i am working on a calendar app n the main screen i have a navigation drawer and i am trying to set a title(Menu) in the middle of the toolbar by using some properties but it does not set it exactly in the middle. 有点问题,如果您能为我提供帮助,我将不胜感激,我正在主屏幕上使用日历应用程序,我有一个导航抽屉,并且我试图在工具栏的中间设置标题(菜单)通过使用一些属性,但它并未将其设置在中间。 In the case of navigation drawer toolbar does not take full width of screen, it does not consider the space taking by navigation_View.
在导航抽屉工具栏未占据整个屏幕宽度的情况下,它不考虑navigation_View占用的空间。
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#3256e1"
android:elevation="4dp"
android:minHeight="?attr/actionBarSize">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_centerVertical="true"
android:text="MENUE"
android:layout_centerHorizontal="true"
android:textColor="@android:color/white" />
<ImageView
android:layout_width="wrap_content"
android:layout_marginRight="8dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/wallet"
/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
工具栏的左边距为16dp,您可以为文本视图设置右边距->您的文本将在工具栏的中心
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.