app:layout_scrollFlags不起作用

解决视图进入与滚动问题
本文探讨了在Android开发中使用enterAlwaysCollapsed属性时遇到的视图进入与滚动问题,解释了其工作原理,并提供了可能导致问题的常见原因及解决策略。

http://stackoverflow.com/questions/31722798/enteralwayscollapsed-does-not-bring-back-the-toolbar-when-scrolling-down/31946043#31946043

1.enterAlwaysCollapsed: 当你的视图已经设置minHeight属性又使用此标志时,你的视图只能已最小高度进入,只有当滚动视图到达顶部时才扩大到完整高度

2. 含有app:layout_scrollFlags的view必须声明在不含该属性的view的布局的前面

 
 

Hard to say without seeing your code, as a guess this could be one of two things:


1.

enterAlwaysCollapsed - This flag defines how View enter back into the screen. When your view has declared a minHeight and you use this flag, your View will only enter at its minimum height (i.e., ‘collapsed’), only re-expanding to its full height when the scrolling view has reached it’s top. Use it with scroll flag like this: scroll|enterAlwaysCollapsed

Anyway it seems like it doesn't work as described in minHeight part.

 


2.

You have not formatted your code correctly.

From Android's Developer Blog I quote on "CoordinatorLayout and the app bar":

One note: all views using the scroll flag must be declared before views that do not use the flag. This ensures that all views exit from the top, leaving the fixed elements behind.

This link also goes into more detail about how to use enterAlwaysCollapsed and is worth looking at.

 

转载于:https://www.cnblogs.com/krislight1105/p/5080798.html

<com.google.android.material.appbar.AppBarLayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true" android:importantForAccessibility="no" app:elevation="0dp" app:layout_constraintTop_toTopOf="parent"> <com.google.android.material.appbar.CollapsingToolbarLayout android:id="@+id/collapse_tl" android:layout_width="match_parent" android:layout_height="match_parent" android:importantForAccessibility="no" app:layout_scrollFlags="scroll|exitUntilCollapsed|snapMargins" app:titleEnabled="true" app:toolbarId="@+id/toolbar"> <View android:id="@+id/profile_bg_iv" android:layout_width="match_parent" android:layout_height="match_parent" android:alpha="0" android:background="?attr/colorSurface" app:layout_collapseMode="parallax" /> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/profile_cl" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="?attr/actionBarSize" android:layout_marginBottom="10dp" app:layout_collapseMode="parallax" app:layout_collapseParallaxMultiplier="0.6"> <com.google.android.material.imageview.ShapeableImageView android:id="@+id/profile_iv" android:layout_width="@dimen/tpds_all_dp_76" android:layout_height="@dimen/tpds_all_dp_76" android:scaleType="centerCrop" android:importantForAccessibility="no" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.MP.ShapeableImageView.Circle" app:srcCompat="@mipmap/ic_avatar_default" /> <com.tplink.design.text.TPTextView android:id="@+id/profile_name_tv" style="@style/Widget.TPDesign.TextView.Primary.Title" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginTop="10dp" android:layout_marginEnd="16dp" android:focusable="true" android:gravity="center" app:markAsAccessibilityHeader="true" app:layout_constraintTop_toBottomOf="@id/profile_iv" tools:text="Finn" /> <com.tplink.design.button.TPUnderlineButton android:id="@+id/profile_edit_tv" style="@style/Widget.TPDesign.TextView.Highlight.Body1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/tpds_all_dp_16" android:layout_marginTop="10dp" android:focusable="true" android:gravity="center" android:minWidth="@dimen/tpds_all_dp_48" android:minHeight="@dimen/tpds_all_dp_48" android:text="@string/parent_control_edit_owner" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@id/profile_name_tv" /> </androidx.constraintlayout.widget.ConstraintLayout> <com.google.android.material.appbar.MaterialToolbar android:id="@+id/toolbar" style="@style/Widget.TPDesign.Toolbar" android:layout_width="match_parent" android:layout_height="@dimen/tpds_all_dp_146" android:background="@color/tpds_transparent" app:layout_collapseMode="pin" app:navigationContentDescription="@string/talkback_back" app:navigationIcon="@drawable/mp_svg_nav_arrow_start" app:titleTextColor="?attr/colorSurface" /> </com.google.android.material.appbar.CollapsingToolbarLayout> </com.google.android.material.appbar.AppBarLayout> 这里折叠后的高度是由哪个决定
07-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值