【发布时间】:2014-11-25 23:21:37
【问题描述】:
我最近尝试在我的一个应用程序中实现 Material Design 大修,并从 HeinrichReimer (material-design) 发现了这个库,用于实现 Material Design 的 Navigation Drawer。
但是,我在显示抽屉的配置文件部分时遇到了问题。我已经按照指南中的说明实现了它:
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
}
})
);
.. 我还添加了一些抽屉项目
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();
}
})
);
下面是我的布局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>
我还不能发布图片(声誉太低),所以下面是我上传到 IMGUR 的应用的屏幕截图: http://i.imgur.com/IaFPzD1.png
会有人碰巧实现这个库吗?你能展示个人资料部分吗?
【问题讨论】:
-
请发布您面临的错误或问题。如果可用,请发布您的堆栈跟踪,以便我们寻求帮助。
-
我相信我已经在我的帖子中指出了这一点:“但是,我在显示抽屉的 Profile 部分时遇到了问题。”
标签: android navigation-drawer android-5.0-lollipop material-design