2
<?xml version="1.0" encoding="utf-8"?>
<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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/nav_header_main" />
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
View child = getLayoutInflater().inflate(R.layout.app_bar_main, null);
drawer.addView(child);
我使用此代码以编程方式将不同的孩子添加到抽屉布局。当我以编程方式添加孩子意味着导航抽屉工作不正常,我的意思是它可以拖出来,但不能拖入。当我接触侧面意味着它正在关闭。任何人都可以知道如何解决这个问题。提前致谢。如何以编程方式在DrawerLayout中包含布局并平滑拖动导航视图?
谢谢,它的工作。 –