einfach versuchen, Ihre Ansicht in Ihrer Tätigkeit finden:
tvUserName = (TextView) findViewById(R.id.tv_username);
Es funktioniert für mich. Mein Kopf Layout ist:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="192dp"
android:background="?attr/colorPrimaryDark"
android:padding="16dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:orientation="vertical"
android:gravity="bottom">
<TextView
android:id="@+id/tv_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
</LinearLayout>
Mein NavigationView in Activity-Layout ist:
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/menu_drawer"/>
Und BTW, Ich habe dieses Problem beim Aufpumpen Linearlayout, in dem Layout params nicht vorgesehen ist:
TextView headerView = (TextView) LayoutInflater.from(this).inflate(R.layout.lay_header, null);
headerView.setText("Your_thoght");
Hoffe es hilft.
Es liegt an Ihnen, was Sie in der Kopf Aufpumpen werden Aussicht. Sie können 'ImageView' in' LinearLayout' aufnehmen und ImageDrawable dynamisch ändern. – Moinkhan
Konnten Sie mehr Details zeigen, ex meine Überschrift nur mit Textview in FrameLayout. –
beziehen Sie sich auf diese Antwort .. http://Stackoverflow.com/a/30660069/3544839 ... – Moinkhan