
[英]How to I use the ActionBarDrawerToggle Functionality without drawerLayout?
[英]Using a DrawerLayout without navigation functionality
我一直在寻找到DrawerLayout
为我的项目的滑出式菜单。 除了一件事,它似乎表现出我想要的方式。
我已经运行了一些示例项目,它们似乎都有一个共同点: DrawerLayout
始终是应用程序的主要部分,如下所示:
setContentView(R.layout.activity_main);
其中activity_main
是:
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
此外, DrawerLayout
似乎与导航有着紧密的联系,在导航中,它通常用于在片段之间跳转。
我的问题是,我不想使用此滑出菜单进行导航,也不想将应用程序的当前主页设为Fragment
。 我需要滑出菜单,但我将主要使用它进行设置,而不是在应用程序中移动。
有没有办法提供一个简单的滑出菜单,该菜单在外观和战术上都类似于DrawerLayout
,而无需将我的所有视图都设置为它的片段?
我最近使用1.使用带有自定义X或Y属性的ViewTreeObserver的自定义RelativeLayout类(对于抽屉,您将使用X)2.引用相同自定义属性的objectAnimator XML 3.使用自定义的UI自身的Fragment类布局类4.使用setCustomAnimations
的方法getFragmentManager
显示/隐藏菜单。
这是一个示例,只需将其更改为水平
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.