Я создал навигационное представление в заголовке app.for, добавил изображение и текстовое представление . Но это выравнивание происходит неправильно. Оно всегда начинается над экраном мобильного телефона.Заранее спасибо.
Вот мой код:
<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"
tools:openDrawer="start">
<include layout="@layout/app_bar_main" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" >
</android.support.design.widget.NavigationView>
HeaderView:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/view_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@color/colorPrimary">
<!-- <ImageView
android:id="@+id/img_header_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:contentDescription="@string/app_name"
android:scaleType="fitXY" />-->
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/img_logo"
android:layout_width="130dp"
android:layout_height="130dp"
android:scaleType="centerCrop"
/>
<!-- <ImageView
android:id="@+id/img_logo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_marginLeft="45dp"
android:layout_marginStart="45dp"
android:contentDescription="@string/app_name"
android:scaleType="fitXY" />-->
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:gravity="center"
android:layout_below="@+id/img_logo"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:layout_centerInParent="true"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/linear_1"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="@+id/relativeLayout2"
android:background="@color/colorSpinnernavihead"
android:visibility="gone">
<Spinner
android:layout_width="match_parent"
android:layout_height="match_parent"
android:spinnerMode="dropdown"
android:popupBackground="@color/colorWhite"
android:dropDownWidth="200dp"
android:backgroundTint="@color/colorBlack"
android:id="@+id/spinner_navigation">
</Spinner>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear_1"
android:layout_alignParentBottom="true"
android:background="@color/colorWhite"
android:orientation="vertical">
<View
android:id="@+id/view_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorGrayNormal"/>
</LinearLayout>