簡體   English   中英

除非工具欄具有layout_scrollflags:scroll,否則CoordinatorLayout滾動將無法正常工作

[英]CoordinatorLayout scroll doesn't work unless Toolbar has layout_scrollflags:scroll

我試圖讓AppBarLayout僅滾動其子級之一,而不滾動其中的ToolBar。

但是,當我從工具欄中刪除layout_scrollflags = scroll時,沒有任何滾動。

AppBarLayout滾動中可能只有一個視圖,而工具欄卻沒有?

  <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?actionBarSize" android:theme="@style/BarTheme" app:title="@string/my"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center|start" android:src="@{ViewModel.showingDropdown ? @drawable/ic_arrow_drop_up_white_24dp : @drawable/ic_arrow_drop_down_white_24dp}" android:tint="@color/ring_blue" android:visibility="@{ViewModel != null ? View.VISIBLE : View.GONE}" /> </android.support.v7.widget.Toolbar> <FrameLayout android:id="@+id/widget_container" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll|enterAlways" /> </android.support.design.widget.AppBarLayout> 

該代碼的結果是沒有任何滾動,但是當我將layout_scrollflags = scroll添加到工具欄時,Toolbar和FrameLayout都滾動了,我不想

為此,請使用折疊式工具欄布局...,並使工具欄collapse_mode = "pin" ,其他的collapse_mode = parallax 您要滾動以供參考的布局,請檢查https://antonioleiva.com/collapsing-toolbar-layout/

  • 將折疊式工具欄布局的父布局保持為appBarlayout。

  • 給它分配滾動標志。

  • 使用所需的collapse_mode (視差,pin等)定義折疊式工具欄布局的子布局。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM