2016-10-18 6 views
0

Ich bin davon 2 Layouts auf meine Tätigkeit xml, jetzt will ich das zweite Layout nicht der erste zu überlappen, aber es gelingt mir nicht wirklich, es zu tun ....Android-Layouts überlappen

Beigefügt ist mein xml . Wie kann ich das erreichen?

<?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" /> 

Auch meine 2 enthalten Layouts 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" /> 

content_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" /> 

Antwort

2

umfassen sowohl Layouts in

<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> 
+0

Ihr für die Antwort danken! –

+0

@ MarnyA.López Sie sind immer willkommen –

+0

@ MarnyA.López Willkommen, Schade, wenn Sie meine Antwort akzeptieren –

0

try Code unten hoffen, dass es Ihnen helfen !!!

<?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> 
1

Platz sowohl in einer RelativeLayout "include" und relativen Abstand zwischen ihnen geben entweder

android:layout_marginTop="15dp" 

oder

android:layout_marginBottom="15dp" 
+0

Vielen Dank für die Antwort! –

+0

Die Hauptinhaltsansicht (oben das FrameLayout) muss das erste untergeordnete Element in der DrawerLayout-Klasse sein, da die XML-Reihenfolge die Z-Reihenfolge impliziert, und die Schublade muss über dem Inhalt stehen. - https://developer.android.com/training/implementing-navigation/nav-drawer.html – elmontoya7