如何更改抽屉标题? [英] How to change the drawer title?
本文介绍了如何更改抽屉标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Android的新手,正在开发App.我正在尝试开发一个具有抽屉式布局的应用程序.一切都很好,但是我无法更改屏幕快照上标记的抽屉菜单的标题.
I am new in Android and working on a App. I am trying to develop an App having drawer layout. Everything is fine but I can't change the Title of the drawer menu as marked on the screenshot.
为方便起见,这里是布局文件.我已从此链接:
Here is the layout file for your convenience. I have taken assistance from this link:
<?xml version="1.0" encoding="utf-8"?>
<!-- Use DrawerLayout as root container for activity -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/user_home_main_view">
<Button
android:id="@+id/button_mutual_funds_icl"
style="@style/Widget.AppCompat.Button"
android:layout_width="252dp"
android:layout_height="49dp"
android:layout_marginTop="120dp"
android:layout_marginEnd="16dp"
android:text="Mutual Funds of ICL"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/icon_mutual_funds_of_icl"
android:layout_width="51dp"
android:layout_height="49dp"
android:layout_marginStart="28dp"
android:layout_marginTop="120dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toStartOf="@+id/button_mutual_funds_icl"
app:layout_constraintHorizontal_bias="0.384"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/mutual_funds_of_icl" />
<Button
android:id="@+id/button_current_nav"
android:layout_width="252dp"
android:layout_height="49dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:text="Current NAVs"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_mutual_funds_icl" />
<ImageView
android:id="@+id/icon_current_nav"
android:layout_width="51dp"
android:layout_height="49dp"
android:layout_marginStart="28dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toStartOf="@+id/button_current_nav"
app:layout_constraintHorizontal_bias="0.458"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/icon_mutual_funds_of_icl"
app:srcCompat="@drawable/net_asset_value" />
<Button
android:id="@+id/button_fund_performance"
android:layout_width="250dp"
android:layout_height="49dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:text="Fund Performance"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_current_nav" />
<ImageView
android:id="@+id/icon_fund_performance"
android:layout_width="51dp"
android:layout_height="49dp"
android:layout_marginStart="28dp"
android:layout_marginTop="26dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toStartOf="@+id/button_fund_performance"
app:layout_constraintHorizontal_bias="0.448"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/icon_current_nav"
app:srcCompat="@drawable/fund_performance" />
<Button
android:id="@+id/button_how_to_invest"
android:layout_width="249dp"
android:layout_height="wrap_content"
android:layout_marginTop="28dp"
android:layout_marginEnd="16dp"
android:text="How to Invest"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_fund_performance" />
<ImageView
android:id="@+id/icon_how_to_invest"
android:layout_width="53dp"
android:layout_height="49dp"
android:layout_marginStart="28dp"
android:layout_marginTop="36dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toStartOf="@+id/button_how_to_invest"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/icon_fund_performance"
app:srcCompat="@drawable/how_to_invest" />
<Button
android:id="@+id/user_home_button_invest_now"
android:layout_width="214dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="141dp"
android:layout_marginEnd="8dp"
android:background="@color/colorPrimary"
android:text="Invest Now"
android:textColor="@color/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.513"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_how_to_invest" />
</android.support.constraint.ConstraintLayout>
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar" />
</FrameLayout>
<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="@+id/user_nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/drawer_view"
app:headerLayout="@layout/nav_header"/>
</android.support.v4.widget.DrawerLayout>
推荐答案
您可以添加自定义标题布局. https://developer.android.com/training/implementing-navigation/nav-drawer#HeaderLayout
You can add custom header layout. https://developer.android.com/training/implementing-navigation/nav-drawer#HeaderLayout
这篇关于如何更改抽屉标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文