Android布局重叠
我在我的活动xml中包含了两个布局,现在我希望第二个布局不要与第一个布局重叠,但我并没有真正做到这一点 附件是我的xml。我怎样才能做到这一点Android布局重叠,android,xml,android-layout,layout,Android,Xml,Android Layout,Layout,我在我的活动xml中包含了两个布局,现在我希望第二个布局不要与第一个布局重叠,但我并没有真正做到这一点 附件是我的xml。我怎样才能做到这一点 <?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.androi
<?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
android:id="@+id/header"
layout="@layout/app_bar_yout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include layout="@layout/content_youtube"
android:layout_above="@id/header"
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" />
我的2个布局中还包括xml
app_bar_yout
<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.mlopezitsolutions.blabla.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
youtube上的内容
<?xml version="1.0" encoding="utf-8"?><RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.mlopezitsolutions.blabla.MainActivity">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
在中包括这两种布局
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/header"
layout="@layout/app_bar_yout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include layout="@layout/content_youtube"
android:layout_marginTop="15dp"
android:layout_below="@id/header"
android:layout_width="match_parent"
android:layout_height="match_parent" /></RelativeLayout>
在中包括这两种布局
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/header"
layout="@layout/app_bar_yout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include layout="@layout/content_youtube"
android:layout_marginTop="15dp"
android:layout_below="@id/header"
android:layout_width="match_parent"
android:layout_height="match_parent" /></RelativeLayout>
试试下面的代码,希望它能帮助你
<?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">
<RelativeLayout
android:id="@+id/toplayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/toolbarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/header"
layout="@layout/app_bar_yout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_below="@+id/toolbarlayout"
android:layout_height="wrap_content">
<include
layout="@layout/content_youtube"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</RelativeLayout>
<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>
试试下面的代码,希望它能帮助你
<?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">
<RelativeLayout
android:id="@+id/toplayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/toolbarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/header"
layout="@layout/app_bar_yout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_below="@+id/toolbarlayout"
android:layout_height="wrap_content">
<include
layout="@layout/content_youtube"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</RelativeLayout>
<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>
将两个“包含”放在一个相对位置,并使用其中一个
android:layout_marginTop="15dp"
或
将两个“包含”放在一个RelativeLayout中,并使用其中一个给出它们之间的相对裕度
android:layout_marginTop="15dp"
或
谢谢你的回复!谢谢你的回复!主内容视图(上面的框架布局)必须是抽屉布局中的第一个子视图,因为XML顺序意味着z顺序,抽屉必须位于内容的顶部。-主内容视图(上面的FrameLayout)必须是抽屉布局中的第一个子视图,因为XML顺序意味着z顺序,抽屉必须位于内容的顶部-