2016-10-12 1 views
1

J'ai un problème lors de l'utilisation de CollapsingToolbarLayout. En fait, je veux coller la barre d'outils, mais le contenu ci-dessous est en mode parallaxe, de sorte qu'il peut masquer défiler vers le haut et afficher lorsque vous faites défiler vers le bas. Cela se produit, mais mon problème est que le contenu de parallélisme linéaire chevauche la barre d'outils.CollapsingToolbarLayout le contenu se superpose à la barre d'outils

J'ai essayé de nombreuses options pour ajouter la barre d'outils et linearlayout dans une autre disposition linéaire avec l'orientation verticale, mais ensuite l'effondrementToolbarLayout cesse de fonctionner.

J'ai également essayé en ajoutant android: fitsSystemWindows = "true" mais cela ne résout pas non plus mon problème. Mon code de mise en page est donné ci-dessous:

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


<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    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="match_parent" 
     android:fitsSystemWindows="true" 
     app:contentScrim="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed" 
     app:titleEnabled="false"> 

     <android.support.v7.widget.Toolbar 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      android:minHeight="?attr/actionBarSize" 
      android:padding="0dp" 
      app:contentInsetLeft="0dp" 
      app:contentInsetStart="0dp" 
      app:layout_collapseMode="pin" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
      app:titleTextAppearance="@style/ToolbarTitle"/> 

      <LinearLayout 
       android:fitsSystemWindows="true" 
       android:layout_below="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" 
       app:layout_collapseMode="parallax"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="Email" 
        android:textColor="@color/white" 
        android:textSize="70dp"/> 
      </LinearLayout> 



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

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

<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#ffe5e5e5" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <android.support.v7.widget.CardView 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:card_view="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/placeCard" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="5dp" 
      card_view:cardCornerRadius="1dp" 
      card_view:cardElevation="3dp"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:padding="10dp"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="General" 
        android:textStyle="bold"/> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="1dp" 
        android:background="@color/gray_transparent3"> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:paddingTop="10dp" 
        android:weightSum="10"> 

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text="Model: "/> 

        <TextView 
         android:id="@+id/textViewModel" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text=""/> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:paddingTop="5dp" 
        android:weightSum="10"> 

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text="SKU: "/> 

        <TextView 
         android:id="@+id/textViewSKU" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text=""/> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:paddingTop="5dp" 
        android:weightSum="10"> 

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text="EAN: "/> 

        <TextView 
         android:id="@+id/textViewEAN" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text=""/> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:paddingTop="5dp" 
        android:weightSum="10"> 

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text="UPC: "/> 

        <TextView 
         android:id="@+id/textViewUPC" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text=""/> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:paddingTop="5dp" 
        android:weightSum="10"> 

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text="Manufacturer: "/> 

        <TextView 
         android:id="@+id/textViewManufacturer" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text=""/> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:paddingTop="5dp" 
        android:weightSum="10"> 

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text="Price: "/> 

        <TextView 
         android:id="@+id/textViewPrice" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text=""/> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:paddingTop="5dp" 
        android:weightSum="10"> 

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text="Quantity: "/> 

        <TextView 
         android:id="@+id/textViewQuantity" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text=""/> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:paddingTop="5dp" 
        android:weightSum="10"> 

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text="Status: "/> 

        <TextView 
         android:id="@+id/textViewStatus" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text=""/> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:paddingTop="5dp" 
        android:weightSum="10"> 

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text="Stock availability: "/> 

        <TextView 
         android:id="@+id/textViewStockAvailability" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text=""/> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" 
        android:paddingTop="5dp" 
        android:weightSum="10"> 

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text="Total Ordered: "/> 

        <TextView 
         android:id="@+id/textViewTotalOrdered" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="5" 
         android:text=""/> 
       </LinearLayout> 
      </LinearLayout> 

     </android.support.v7.widget.CardView> 

     <android.support.v7.widget.CardView 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:card_view="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/placeCardDescription" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="5dp" 
      card_view:cardCornerRadius="1dp" 
      card_view:cardElevation="3dp"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:padding="10dp"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="Description" 
        android:textStyle="bold"/> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="1dp" 
        android:background="@color/gray_transparent3"> 
       </LinearLayout> 

       <TextView 
        android:id="@+id/textViewHtmlDescription" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:paddingTop="10dp" 
        android:text="" 
        /> 


      </LinearLayout> 
     </android.support.v7.widget.CardView> 
    </LinearLayout> 

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

Et la sortie est comme le fichier joint: enter image description here

Je dois que le contenu « Envoyer » commencera à partir du bas de la barre d'outils avec effet d'effondrement.

Aidez-moi à résoudre ce problème.

Répondre

-1

Vous pouvez le faire dans onCreate(), cela ne se chevauchent pas les titres

final CollapsingToolbarLayout mCollapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbar); 
    AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appBar); 

    appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { 
     @Override 
     public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { 
      if (verticalOffset == 0 || verticalOffset <= toolbarInPerspectiveActivity.getHeight() && !toolbarInPerspectiveActivity.getTitle().equals(mCollapsedTitle)) { 
       mCollapsingToolbar.setTitle(mExpandedTitle); 
      } else if (!toolbarInPerspectiveActivity.getTitle().equals(mExpandedTitle)) { 
       mCollapsingToolbar.setTitle(mCollapsedTitle); 
      } 
     } 
    }); 

Et Pour le titre agrandi et effondré titre où vous mettre le titre de la barre d'outils.