2016-10-16 2 views
1

Hallo Leute, hilf mir mit meinem Problem mit meinem Listenansicht mit Navigation. Ughh, Weil ich meine normale Seite mit Tabs nicht dazu bringen kann, eine Navigationsschublade hinzuzufügen, hier ist mein versauter Code, danke Jungs. Dieser Code funktioniert, aber meine Fab-Buttons fehlen im Layout.Android Tab mit Navigation

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

    <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:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.example.kun.carkila.OwnerTabs"> 
     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="#990000" 
       app:popupTheme="@style/Theme.AppCompat.Light.DarkActionBar"/> 

      <android.support.design.widget.AppBarLayout 
       android:id="@+id/appbar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:paddingTop="@dimen/appbar_padding_top" 
       android:theme="@style/AppTheme.AppBarOverlay" 
       android:background="#990000"> 

       <android.support.design.widget.TabLayout 
        android:id="@+id/tabs" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"/> 

      </android.support.design.widget.AppBarLayout> 

      <android.support.v4.view.ViewPager 
       android:id="@+id/container" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

      <android.support.design.widget.FloatingActionButton 
       android:id="@+id/fab1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="top|left" 
       android:layout_margin="@dimen/fab_margin" 
       app:srcCompat="@drawable/plus" 
       app:layout_anchor="@+id/container" 
       app:layout_anchorGravity="bottom|right" /> 

      <android.support.design.widget.FloatingActionButton 
       android:id="@+id/fab" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="top|left" 
       android:layout_margin="@dimen/fab_margin" 
       app:srcCompat="@drawable/car" 
       app:layout_anchor="@+id/container" 
       app:layout_anchorGravity="bottom|right" /> 
     </LinearLayout> 

    </android.support.design.widget.CoordinatorLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:menu="@menu/nav_menu"/> 

</android.support.v4.widget.DrawerLayout> 

Antwort

0

Sie müssen fab Taste als Kind von CoordinateLayout verwenden nicht das Kind von Linearlayout und sollte Symbolleiste als Kind von appbarlayout

Notiz verwenden: AppbarLayout ist kundenspezifische Linearlayout

CoordinateLayout Brauch ist framelayout

Verwenden Sie dieses Layout

<?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:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.example.kun.carkila.OwnerTabs"> 



     <android.support.design.widget.AppBarLayout 
      android:id="@+id/appbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:paddingTop="8dp" 
      android:theme="@style/AppTheme.AppBarOverlay" 
      android:background="#990000"> 


      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="#990000" 
       app:popupTheme="@style/Theme.AppCompat.Light.DarkActionBar"/> 

      <android.support.design.widget.TabLayout 
       android:id="@+id/tabs" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"/> 

     </android.support.design.widget.AppBarLayout> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/container" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="top|left" 
      android:layout_margin="16dp" 
      app:srcCompat="@drawable/ic_create_black_24px" 
      app:layout_anchor="@+id/container" 
      app:layout_anchorGravity="bottom|right" /> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="top|left" 
      android:layout_margin="16dp" 
      app:srcCompat="@drawable/ic_comment_white_24px" 
      app:layout_anchor="@+id/container" 
      app:layout_anchorGravity="bottom|right" /> 

</android.support.design.widget.CoordinatorLayout> 

<android.support.design.widget.NavigationView 
    android:id="@+id/navigation_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    />