У меня есть простой DrawerLayout, который содержит некоторый основной контент (все они хорошо отображаются), блок навигации, который является только RelativeLayout (id: boxPane) и ListView (который я заполнил BaseAdapter).
Моя цель - вставить в ящик несколько изображений над элементами навигации. Я попытался вставить это изображение (конечно, в пределах панели), инкапсулировав его в LinearLayout, RelativeLayout, поместив его самостоятельно, но изображение не показывается.
Как вставить это изображение в Drawer над элементами навигации?
Вот XML с короткими комментариями.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.ProfileActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<!-- Add this, so AppBarLayout has a bug, which causes ViewPager not to show listview entirely on the screen
Adding this view fixes (workaround) the problem -->
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorPrimary" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways">
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center|top"
android:background="@android:color/white"
>
//Here I have bunch of small components which are displayed nicely
</LinearLayout>
<!--Navigation drawer-->
<RelativeLayout
android:layout_width="280dp"
android:layout_height="match_parent"
android:id="@+id/drawerPane"
android:layout_gravity="start">
<!--Profile box here-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical"
android:layout_gravity="start">
<!--This is the image which I cannot place in the drawer. Busting my head for daaays.-->
<ImageView
android:layout_gravity="start"
android:layout_width="match_parent"
android:layout_height="100dp"
android:src="@drawable/welcome_logo"
android:layout_above="@+id/drawerList">
</ImageView>
</LinearLayout>
<!-- List of Actions (pages) -->
<ListView
android:id="@+id/drawerList"
android:layout_width="280dp"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:background="#ffffffff" />
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
</LinearLayout>