我正在尝试分配dailyImage
nav_header.xml
MainActivity
班
setContentView(R.layout.activity_main);
我能够在nav\U操作中分配视图。xml,但不在nav_header.xml中。
保持这样,有什么方法可以分配吗
nav\u header.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="@android:color/holo_blue_dark"
android:padding="10dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
tools:context="com.example.hello.world.MainActivity">
<ImageView
android:id="@+id/DailyImage"
android:layout_width="match_parent"
android:layout_height="108dp"
android:layout_below="@+id/menu_text"
android:layout_alignParentStart="true" />
</RelativeLayout>
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/nav_drawer_main"
android:background="@color/gray"
android:orientation="vertical"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/nav_action"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:layout_width="260dp"
android:layout_height="match_parent"
android:id="@+id/nav_men"
android:background="@color/black"
app:menu="@menu/nav_menu"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header"
app:itemIconTint="@drawable/drawer_item"
app:itemTextColor="@drawable/drawer_item">
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>