6

我使用下面的佈局,它在除了Android Nougat之外的所有版本都很好用,當完全摺疊時標題被切斷。當在牛軋糖上運行時,爲什麼在使用CollapsingToolbarLayout時標題會被切斷?

enter image description here

<android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="300dp" 
      android:fitsSystemWindows="true" 
      app:contentScrim="@color/them_color" 
      app:expandedTitleTextAppearance="@android:color/transparent" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <ImageView 
       android:id="@+id/header_image" 
       android:layout_width="match_parent" 
       android:layout_height="300dp" 
       android:contentDescription="@string/app_name" 
       android:fitsSystemWindows="true" 
       android:scaleType="fitXY" 
       app:layout_collapseMode="parallax"/> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?android:attr/actionBarSize" 
       app:layout_collapseMode="pin" 
       app:contentInsetLeft="0dp" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 

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

我試圖app:collapsedTitleGravity="center",但它並沒有解決問題。我如何使它成爲牛軋糖的工作?

+0

是否有人面臨同樣的問題? – user2881604

+0

這是完美的片段,但不在活動。任何人都有一個想法,只有在活動? – user2881604

回答

7

問題是reported

沒有比消除fitsSystemWindows, 甚至更​​好的選擇,只需添加到onCreatecollapsingToolbarLayout.post { collapsingToolbarLayout.requestLayout() }

+0

感謝您提及此問題,尤其是解決方法,但請注意,如果沒有'Runnable',您的post-block將無法正常工作。 – reVerse

+0

@reVerse這段代碼寫在[kotlin](https://kotlinlang.org/) – panbacuh

+0

感謝您指出這一點。沒有意識到這一點。 – reVerse

1

是的,這很煩人。

我來這裏尋找解決它,所以我沒有解決方案,但我只能說,如果你切換到分屏後退,問題就會消失。

也許這個事實可以指導某人更接近解決方案。

編輯:只需從AppBarLayout中移除fitsSystemWindows;那是爲我做的。

3

去除機器人:fitsSystemWindows = 「真」 解決我的問題

+0

謝謝,它也適用於我 –

相關問題