MaterialDrawer icon indicating copy to clipboard operation
MaterialDrawer copied to clipboard

Custom header

Open afeozzz opened this issue 11 years ago • 5 comments

I noticed that if i want use background image in header, custom header height changes if image will not is same height as header.

example of my custom header

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="190dp"
            android:background="@mipmap/blur_background"
            android:orientation="vertical">

<de.hdodenhof.circleimageview.CircleImageView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/profile_image"
    android:layout_width="56dp"
    android:layout_height="56dp"
    android:src="@mipmap/ic_user_avatar_default"
    app:border_color="#FF000000"
    android:layout_marginTop="96dp"
    android:layout_marginLeft="24dp"
    android:layout_marginStart="24dp"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Akash Bangad"
    android:textSize="14sp"
    android:textColor="#FFF"
    android:textStyle="bold"
    android:gravity="left"
    android:layout_marginLeft="24dp"
    android:id="@+id/username"
    android:layout_marginTop="8dp"
    android:layout_marginBottom="8dp"/>
</LinearLayout>

my background was 200&390 , so height of header specifies the height of the header image and it was wrong.

I hope you fix it

afeozzz avatar Oct 31 '15 00:10 afeozzz

@afeozzz nothing i can fix. If you provide a custom header only the view you provide is used.

If you set a layout as header it will be wrapped into a ContainerDrawerItem and added to the list on the first position so it will work as any list item.

The layout which will contain yours is a normal LinearLayout with width MATCH_PARENT and height WRAP_CONTENT

mikepenz avatar Oct 31 '15 11:10 mikepenz

I've stumbled across the same issue:

To reproduce just use a FrameLayout with height set to 150dp and a background image which exceeds this height (e.g. 200dp). When adding the header via withHeader(R.layout.header) the resulting header view has the height of the background and not the static 150dp.

couchcrew-thomas avatar Feb 23 '16 09:02 couchcrew-thomas

@couchcrew-thomas as mentioned in the previous answer. That's the way the RecyclerView from Android handles the items. If you wrap the whole thing in a LinearLayout with a specific height it should work

mikepenz avatar Feb 23 '16 09:02 mikepenz

I open an issue about 10 minutes ago. After your last answer @mikepenz I tried to put an ImageView inside LInearLayout, and this Linear has 200 dp height. Solution doesn not work

multivoltage avatar Apr 30 '16 08:04 multivoltage

Note for anyone else trying to solve this problem, make sure you use drawer.setHeader(yourView, false). Without use of the second boolean, whatever settings you provided on drawer initialization are overrided, and the divider will be displayed anyways.

Kraahkan avatar Jul 19 '17 16:07 Kraahkan