适用于较低 API 的 Android Material Design 抽屉导航

标签 android android-layout navigation-drawer material-design

是否可以在较低 API 上像 Gmail 应用程序那样在 Material Design 中制作抽屉导航? 如果有可能有人有教程或指南来做这件事吗? 谢谢

最佳答案

为此使用 Appcompat 库,这里有一个如何设置它的链接:http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-pre.html

您需要使用工具栏来显示箭头切换:

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>

在您的 mainView 中,您需要添加以下内容:

setContentView(R.layout.guidelib_activity_main);
mToolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);

另请参阅此问题:Appcompat Toolbar Not Showing With Navigation Drawer

关于适用于较低 API 的 Android Material Design 抽屉导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27969452/

相关文章:

android - Monodroid - 绘制叠加层并在相机预览上放置一个按钮

android - 在右抽屉的双抽屉导航中禁用抽屉图标的动画

android - 如何将带有标记的 map 添加到android中的适配器项目?

android - CardView如何显示多列?

android - 旋转后的垂直 TextView 定位

android - 后退按钮转到另一个 Activity 而不是 Android 中的父 Activity

android - 使用 appcompat v7 不显示抽屉导航图标

android - 是否可以使用带有导航绘制的 fragment 并在操作栏中显示图标

java.lang.SecurityException : Binder invocation to an incorrect interface on Android 6 错误

Android 应用程序每天只检查一次登录