Ruffy Heredia
Ruffy Heredia

Reputation: 11

Profile Not Showing on material-drawer

I've recently tried to implement a Material Design overhaul in one of my apps, and came across this library from HeinrichReimer (material-design) on implementing the Navigation Drawer for Material Design.

However, I'm getting a problem with showing the Profile part of the Drawer. I've implemented it as shown in the guide:

drawer.setProfile(
                new DrawerProfile()
                        .setAvatar(getResources().getDrawable(R.drawable.zild))
                        .setBackground(getResources().getDrawable(R.drawable.zild))
                        .setName(getString(R.string.app_name))
                        .setDescription(getString(R.string.hello_blank_fragment))
                        .setOnProfileClickListener(new DrawerProfile.OnProfileClickListener() {
                            @Override
                            public void onClick(DrawerProfile drawerProfile) {
                                // do nothing yet
                            }
                        })
        );

.. and I've also added some drawer items

drawer.addItem(
                new DrawerItem()
                        .setImage(getResources().getDrawable(R.drawable.ic_launcher))
                        .setTextPrimary("My Entries")
                        .setTextSecondary("Yay Entries!")
                        .setOnItemClickListener(new DrawerItem.OnItemClickListener() {
                            @Override
                            public void onClick(DrawerItem drawerItem, int i) {
                                Toast.makeText(HomeActivity.this, "Clicked first item", Toast.LENGTH_LONG).show();
                            }
                        })
        );

        drawer.addDivider();

        drawer.addItem(new DrawerItem()
                        .setImage(getResources().getDrawable(R.drawable.ic_launcher))
                        .setTextPrimary("Settings")
                        .setTextSecondary("Woohoo Settings!")
                        .setOnItemClickListener(new DrawerItem.OnItemClickListener() {
                            @Override
                            public void onClick(DrawerItem drawerItem, int i) {
                                Toast.makeText(HomeActivity.this, "Clicked second item", Toast.LENGTH_LONG).show();
                            }
                        })
        );

Below is my layout xml:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >

    <android.support.v7.widget.Toolbar
        android:id="@+id/timelog_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/timelog_primary"
        android:minHeight="?attr/actionBarSize"
        app:theme="@style/ThemeOverlay.AppCompat.ActionBar" />

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:context=".HomeActivity">

        <!-- The main content view -->
        <FrameLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </FrameLayout>

        <!-- The navigation drawer -->
        <com.heinrichreimersoftware.material_drawer.DrawerView
            android:id="@+id/drawer"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:fitsSystemWindows="true" />

    </android.support.v4.widget.DrawerLayout>

</LinearLayout>

I'm not able to post images yet (reputation too low), so below is a screenshot of my app uploaded to IMGUR: https://i.sstatic.net/rIZpK.png

Would anybody happen to implement this library? And were you able to show the profile part?

Upvotes: 0

Views: 400

Answers (1)

SWAppDev
SWAppDev

Reputation: 248

This is indeed an issue with current Version, i have solved it by updating the code with this pull request:

https://github.com/HeinrichReimer/material-drawer/pull/8

Upvotes: 2

Related Questions