0
我想在我的抽屜式導航欄中添加一個頭。 我是一個Android工作室的初學者,所以任何提示將幫助我很多導航抽屜標題已結束內容?
問題是這個標題是在我的導航抽屜itens,所以我不能看到我的一些導航抽屜itens。
我怎樣才能正確地添加這個頭?另外,我的textview內容沒有顯示,爲什麼?
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="com.sk.mf.UserAreaActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:id="@+id/drawerLayout">
<FrameLayout
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:id="@+id/content_frame">
</FrameLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:menu="@layout/navigation_menu"
android:layout_gravity="start">
<RelativeLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/colorPrimary">
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:id="@+id/nh_User"
android:textSize="24sp"
android:textColor="#ffffff" />
</RelativeLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
塔你的朋友!所以我的textview也會在nav_header.xml中呢?這樣做,我該如何在標題內的文本視圖中添加文本?因爲我有'的setContentView(R.layout.base_activity);'這個XML和'nh_User.setText(用戶名);'添加一些文字在這個TextView的,而是建立一個nav_header.xml我不能引用'nh_User'了...... –
我已經編輯了答案@RickJoe – rafsanahmad007
非常感謝你! –