5

रीसाइक्लिंग के दौरान ढहने के बाद टूलबार को छुपाने के लिए कैसे देखें, रीसाइक्लिंग के दौरान टूलबार दिखाएं, स्क्रॉलिंग देखें, और सूची के अंत में CollapsingToolbarLayout का विस्तार करें? अब CollapsingToolbarLayout बस पतन हो, और स्क्रॉल करते समय टूलबार हर समय दिखा रहा है।रीसाइक्लिंग के दौरान ढहने के बाद टूलबार को छिपाने के लिए कैसे देखें

<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/coordinatorlayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".screens.MainActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/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" 
      android:minHeight="@dimen/actionBarHeight" 
      app:contentScrim="@color/colorPrimary" 
      app:expandedTitleTextAppearance="@style/TransparentText" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <ImageView 
       android:id="@+id/toolbar_image" 
       android:layout_width="match_parent" 
       android:layout_height="180dp" 
       android:adjustViewBounds="true" 
       android:background="#229944" 
       android:contentDescription="@null" 
       android:scaleType="fitCenter"/> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="@dimen/actionBarHeight" 
       android:minHeight="@dimen/actionBarHeight" 
       app:layout_collapseMode="pin" 
       app:layout_scrollFlags="scroll|enterAlwaysCollapsed" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 

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

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:layout_gravity="bottom" 
      app:layout_scrollFlags="scroll" /> 

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

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

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

'ऐप को हटाया जा सकता है: layout_collapseMode =" pin "' काम करना चाहिए। एक विचार है। –

उत्तर

1

आप टूलबार के व्यवहार को बदलना चाहते हैं। आप layout_scrollFlags को बदलकर स्क्रॉल व्यवहार प्रदान कर सकते हैं।

app:layout_scrollFlags="scroll|enterAlways" 

pin हटाएं और यह टूलबार में यह परिवर्तन करें और यह काम करेगा!

+0

यह काम नहीं करता है ( – preceptron

0
  • में android:fitsSystemWindows="true" जोड़ें।
  • Toolbar से app:layout_scrollFlags="scroll|enterAlwaysCollapsed" हटाएं।
  • TabLayoutCollapsingToolbarLayout के अंदर ले जाएं।

    <android.support.design.widget.AppBarLayout 
        android:id="@+id/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" 
         android:minHeight="@dimen/actionBarHeight" 
         app:contentScrim="@color/colorPrimary" 
         app:expandedTitleTextAppearance="@style/TransparentText" 
         app:layout_scrollFlags="scroll|exitUntilCollapsed"> 
    
         <ImageView 
          android:id="@+id/toolbar_image" 
          android:layout_width="match_parent" 
          android:layout_height="180dp" 
          android:adjustViewBounds="true" 
          android:background="#229944" 
          android:contentDescription="@null" 
          android:scaleType="fitCenter"/> 
    
         <android.support.v7.widget.Toolbar 
          android:id="@+id/toolbar" 
          android:layout_width="match_parent" 
          android:layout_height="@dimen/actionBarHeight" 
          android:minHeight="@dimen/actionBarHeight" 
          app:layout_collapseMode="pin" 
          app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 
    
         <android.support.design.widget.TabLayout 
          android:id="@+id/tabs" 
          android:layout_width="match_parent" 
          android:layout_height="?attr/actionBarSize" 
          android:layout_gravity="bottom" 
          app:layout_scrollFlags="scroll" /> 
    
        </android.support.design.widget.CollapsingToolbarLayout> 
    
    </android.support.design.widget.AppBarLayout> 
    
    <android.support.v7.widget.RecyclerView 
        android:id="@+id/content" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 
    

+0

यह काम नहीं करता है (टूलबार शो वैसे भी। और टैबबार ओवरले टूलबार, क्योंकि CollapsingToolbarLayout FrameLayout है। – preceptron

+0

@preceptron आपके कोड में, यह 'FrameLayout' का कोई संकेत नहीं दिखाता है –

2

यह पूरी तरह से काम करना चाहिए। परीक्षण और एपीआई 17

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

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appBar" 
     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="wrap_content" 
      android:fitsSystemWindows="true" 
      app:contentScrim="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"> 

      <ImageView 
       android:id="@+id/background" 
       android:layout_width="match_parent" 
       android:layout_height="256dp" 
       android:scaleType="centerCrop" 
       android:fitsSystemWindows="true" 
       app:layout_collapseMode="parallax" 
       android:src="@drawable/placeholder"/> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:contentScrim="?attr/colorPrimary" 
       android:fitsSystemWindows="true" 
       app:titleTextColor="@color/main_color_white" 
       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" 
      android:background="?attr/colorPrimary" 
      app:tabIndicatorColor="@color/colorAccent" 
      app:tabSelectedTextColor="@color/colorAccent" 
      app:tabTextColor="@android:color/white" 
      app:tabIndicatorHeight="4dp" 
      app:tabMode="fixed"/> 

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

    <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.CoordinatorLayout> 
0

में काम कर CollapsingToolbarLayout उपयोग स्क्रॉल झंडे के लिए:

app:layout_scrollFlags="scroll|enterAllwaysCollapsed" 

इस ध्वज संयोजन उपकरण पट्टी गायब हो जाएगा स्क्रॉल करते समय। और जब आप सूची के शीर्ष पर स्क्रॉल करते हैं तो CollapsingToolbarLayout पूरी तरह विस्तारित होगा।

और Toolbar से app:layout_collapseMode="pin" दूर करने के लिए, क्योंकि collapseMode झंडे व्यवहार और CollapsingToolbarLayout अंदर विचारों की नियुक्ति को परिभाषित कर रहे हैं और वास्तविक गिर और CollapsingToolbarLayout के विस्तार को प्रभावित नहीं होगा कोई जरूरत नहीं।

संबंधित मुद्दे

 संबंधित मुद्दे