1

können dies ist mein Xml Layout:wie CollapsingToolbarLayout unter Symbolleiste

<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_gravity="right" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 

    <android.support.design.widget.CoordinatorLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/main_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true"> 

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

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/appbar" 
      android:layout_width="match_parent" 
      android:layout_height="250dp" 
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
      android:fitsSystemWindows="true"> 


      <android.support.design.widget.CollapsingToolbarLayout 
       android:id="@+id/collapsing_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="210dp" 
       app:layout_scrollFlags="scroll|exitUntilCollapsed" 
       android:fitsSystemWindows="true" 
       app:contentScrim="?attr/colorPrimary" 
       app:expandedTitleMarginStart="48dp" 
       app:expandedTitleMarginBottom="20dp" 
       app:expandedTitleMarginEnd="64dp"> 


       <ImageView 
        android:src="@drawable/img" 
        android:id="@+id/backdrop" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:scaleType="centerCrop" 
        android:fitsSystemWindows="true" 
        app:layout_collapseMode="parallax" /> 

       <android.support.v7.widget.Toolbar 
        android:textAlignment="center" 
        android:id="@+id/toolbar" 
        app:titleTextColor="@color/black" 
        android:layout_width="match_parent" 
        android:layout_height="?attr/actionBarSize" 
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
        app:layout_collapseMode="pin" /> 

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

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

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

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


    <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:background="#fff" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/nav_header_main" 
     app:itemIconTint="@color/colorPrimary" 
     app:itemTextColor="@color/black" 
     app:menu="@menu/activity_main_drawer" /> 

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

das ist mein Standard-Ausgabe:

enter image description here

und dies ist meine Ausgabe, wenn drag up Registerkarten: enter image description here

aber ich möchte meine App so werden: enter image description here

wenn ziehen Tabs nur Bild zwischen Symbolleiste und Tabs gegangen ... Ich versuche so viele Möglichkeiten, aber nicht funktionieren. wenn jemand kann bitte helfen

Antwort

0

Versuchen Sie diese: (Kleiner Trick mit RelativeLayout & LinearLayout)

<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:layout_gravity="right" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/main_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true"> 

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

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/appbar" 
      android:layout_width="match_parent" 
      android:layout_height="250dp" 
      android:fitsSystemWindows="true" 
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

      <android.support.design.widget.CollapsingToolbarLayout 
       android:id="@+id/collapsing_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="210dp" 
       android:fitsSystemWindows="true" 
       app:contentScrim="?attr/colorPrimary" 
       app:expandedTitleMarginBottom="20dp" 
       app:expandedTitleMarginEnd="64dp" 
       app:expandedTitleMarginStart="48dp" 
       app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

       <LinearLayout 
        android:layout_width="match_parent" 
        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:textAlignment="center" 
         app:layout_collapseMode="pin" 
         app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

        <RelativeLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@+id/toolbar" 
         android:fitsSystemWindows="true" 
         android:gravity="bottom" 
         android:paddingLeft="30dp" 
         android:scaleType="centerCrop"> 

         <ImageView 
          android:id="@+id/backdrop" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:fitsSystemWindows="true" 
          android:scaleType="centerCrop" 
          android:src="@mipmap/ic_launcher" 
          app:layout_collapseMode="parallax" /> 

        </RelativeLayout> 
       </LinearLayout> 
      </android.support.design.widget.CollapsingToolbarLayout> 

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

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

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

    <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:background="#fff" 
     android:fitsSystemWindows="true" 
     app:itemIconTint="@color/colorPrimary" /> 

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

Ausgang:

enter image description here

Wie Sie :) angefordert

+0

excelent ! mein Bürger;). ist möglich Symbolleiste nicht gegangen, wenn scollup? nur Bild weg ?! – erfan

+0

Wenn ich es nach oben scrolle, wird auch die Symbolleiste ausgeblendet –

Verwandte Themen