0
ナビゲーション・ドロワーにヘッダーを追加しようとしています。 私はアンドロイドスタジオの初心者ですから、どんなヒントも私を助けてくれるでしょうナビゲーションドロワーのヘッダーがコンテンツの上にありますか?
問題は、このヘッダーがナビゲーションドロワーの上にあることです。私は自分のナビゲーションドロワー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>
thaあなたは友よ!だから私のtextviewはnav_header.xmlにもありますか?それを行うにはどうすればヘッダー内のテキストビューにテキストを追加できますか?このxmlの 'setContentView(R.layout.base_activity);とこのテキストビューにテキストを追加するための' nh_User.setText(Username); 'がありますが、nav_header.xmlを作成するので、' nh_User'をもう参照できません... –
回答を編集しました@RickJoe – rafsanahmad007
ありがとうございます! –