- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个详细信息页面,其中包括 CoordinatorLayout 中的 CollapsingToolbarLayout 和 NestedScrollView。当我从 CollapsingToolbarLayout 向上滚动并从 NestedScrollView 非常快速且立即向下滚动时,它会闪烁并且不会为我提供平滑的滚动。它也发生在 Cheesesquare 中演示应用程序。但是,在 Whatsapp 个人资料页面中,它不会发生。
为了更好地理解,这里有一个视频: http://sendvid.com/4xsrya3w
这是我的页面布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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/fragmentPdpCoordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:descendantFocusability="beforeDescendants"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/fragmentPdpAppbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_behavior="com.altayer.nisnass.ui.behaviour.NoBounceBehavior">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/fragmentPdpCollapsingToolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/pdp_toolbar_layout_height"
android:fitsSystemWindows="true"
app:collapsedTitleTextAppearance="@style/PdpToolbarCollapsedTitleText"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginBottom="@dimen/component_margin_medium"
app:expandedTitleMarginStart="@dimen/component_margin_medium"
app:expandedTitleTextAppearance="@style/PdpToolbarExpandedTitleText"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:statusBarScrim="?attr/colorPrimary">
<!--Do not change the id of this view to anything else it needs to be the same
as the root ID of the included layout-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/pdp_image_viewer_height"
android:layout_gravity="center"
app:layout_collapseMode="parallax">
<com.altayer.nisnass.ui.views.imageviewer.ImageViewer
android:id="@+id/fragmentPdpImageViewer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.altayer.nisnass.plp.badge.BadgeListView
android:id="@+id/fragmentPdpBadgeListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/pdp_badge_bottom_margin" />
</RelativeLayout>
<androidx.appcompat.widget.Toolbar
android:id="@+id/fragmentPdpToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetEnd="@dimen/pdp_toolbar_title_margin_end"
app:layout_collapseMode="pin">
<com.altayer.nisnass.ui.views.NisnassImageView
android:id="@+id/fragmentPdpToolbarImageViewThumbnail"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:adjustViewBounds="true" />
</androidx.appcompat.widget.Toolbar>
<include
layout="@layout/fragment_pdp_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/fragmentPdpScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="@+id/fragmentPdpLinearLayoutDescriptionHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<com.altayer.nisnass.pdp.pdpviews.descriptionheader.DescriptionHeader
android:id="@+id/fragmentPdpDescriptionHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View
style="@style/Separator.Horizontal"
android:layout_marginBottom="@dimen/component_margin_small" />
<com.altayer.nisnass.pdp.pdpviews.pdpcarousels.PdpCarousels
android:id="@+id/fragmentPdpCarousels"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Space
android:layout_width="0dp"
android:layout_height="@dimen/cta_button_layout_height" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<!-- TODO: This is a workaround to apply elevation like in design -->
<androidx.cardview.widget.CardView
android:id="@+id/fragmentPdpButtonAddToBagCardView"
style="@style/NisnassCTAButtonOverlay"
android:layout_width="match_parent"
android:layout_height="@dimen/cta_button_layout_height"
android:layout_gravity="bottom"
tools:visibility="gone">
<com.altayer.nisnass.ui.views.NisnassButton
android:id="@+id/fragmentPdpCardViewButtonAddToBag"
style="@style/NisnassButton.CTA"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/cta_button_margin"
android:text="@string/fragment_pdp_add_to_bag" />
</androidx.cardview.widget.CardView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fragmentPdpFloatingActionButtonPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:visibility="gone"
app:backgroundTint="@color/white"
app:layout_anchor="@id/fragmentPdpAppbar"
app:layout_anchorGravity="bottom|right|end"
app:srcCompat="@drawable/ic_play"
app:useCompatPadding="true" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/fragmentPdpFrameLayoutFABBag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="@dimen/activity_general_vertical_margin"
android:clipChildren="false"
android:clipToPadding="false"
android:gravity="center"
android:visibility="gone"
tools:visibility="visible">
<ProgressBar
android:id="@+id/fragmentPdpProgressBarFabBag"
style="?android:attr/progressBarStyleLarge"
android:indeterminateTint="@color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/fragmentPdpFABBag"
app:layout_constraintEnd_toEndOf="@+id/fragmentPdpFABBag"
app:layout_constraintStart_toStartOf="@+id/fragmentPdpFABBag"
app:layout_constraintTop_toTopOf="@+id/fragmentPdpFABBag" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fragmentPdpFABBag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:tint="@color/white"
app:fabSize="normal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/ic_fullfilled_bag"
app:useCompatPadding="true" />
<com.altayer.nisnass.ui.views.NisnassTextView
android:id="@+id/fragmentPdpTextViewBagCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:elevation="12dp"
android:focusableInTouchMode="false"
android:gravity="center"
android:includeFontPadding="false"
android:paddingTop="@dimen/fragment_confirmation_bag_count_margin_top"
android:textAppearance="@style/NisnassTextAppearance.Medium.Small"
android:textColor="@color/black"
app:layout_constraintBottom_toBottomOf="@id/fragmentPdpFABBag"
app:layout_constraintEnd_toEndOf="@id/fragmentPdpFABBag"
app:layout_constraintStart_toStartOf="@id/fragmentPdpFABBag"
app:layout_constraintTop_toTopOf="@id/fragmentPdpFABBag"
tools:text="10" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/cta_button_layout_height"
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:layout_behavior="com.altayer.nisnass.colorandsize.ColorAndSizeBottomSheetBehavior">
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
我正在使用:
'androidx.appcompat:appcompat:1.0.2'
'com.google.android.material:material:1.0.0'
最佳答案
这背后的原因是因为当我们开始在 CoordinatorLayout
的任何其他 View 上转换时,AppBarLayout
不会停止转换。解决方案非常简单:每当 CoordinatorLayout
的任何 subview 开始 fling 时,我们需要停止 AppBarLayout
的 fling(下面的代码适用于 androidx)
class CustomAppBarBehavior : AppBarLayout.Behavior() {
private var overScroller: OverScroller? = null
override fun onNestedPreFling(coordinatorLayout: CoordinatorLayout,
child: AppBarLayout,
target: View,
velocityX: Float,
velocityY: Float): Boolean {
stopAppBarLayoutFling()
return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY)
}
private fun stopAppBarLayoutFling() {
if (overScroller == null) {
val scrollerField = javaClass.superclass.superclass.superclass.getDeclaredField("scroller")
scrollerField.isAccessible = true
overScroller = scrollerField.get(this) as? OverScroller
}
overScroller?.forceFinished(true)
}
}
在支持版本 27 中,通过反射找到滚动条有点不同:
val scrollerField = javaClass.superclass.superclass.getDeclaredField("mScroller")
关于android - 向下滚动时 CollapsingToolbarLayout 闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53629392/
我指的是 Cheesesquare app.我目前的设计要求略有不同.. 像这样的(忽略图片和名称下面的部分) 我想要圆形图像右下角的 float 操作按钮和它下面的人的名字(这将是 Collapsi
我在给定 ScrollingActivity 的 Android Studio 中的 CollapsingToolbarLayout 有问题。 向下滚动 Action 完美无缺,但当我想向上滚动时,它
我正在尝试将包含 ImageView 按钮和其他 UI 元素的 LinearLayout 放置在 CollapsingToolbarLayout 中,这可能吗? 最佳答案 CollapsingTool
我正在使用 CollapsingToolbarLayout 和一个 viewpager。 Viewpager 由 RecyclerView 组成。但是,当滚动回收器 View 时,工具栏不会折叠。 a
我正在尝试控制 collpasingtoolbarlayout 的快照滚动标志的滚动行为。按照这个教程linkSCROLL_FLAG_SNAP:在滚动结束时,如果 View 只是部分可见,那么它将被捕
我正在为我的 fragment (选项卡)使用 CollapsingToolbarLayout 和 View 页面。
如果我将依赖项从 23.1.1 更新到 23.2.0,CollapsingToolbarLayout 将无法正常工作。应用崩溃并抛出错误。 java.lang.RuntimeException:and
在我的 CoordinatorLayout 中,我有以下安排: 我希望我的自定义 T
我在使用 Android 设计支持库时发现我的应用程序存在问题,因为 CollapsingToolbarLayout 顶部似乎有一个主题色背景栏,即使有足够的空间(因此它应该是“透明的” '). 知道
我开始在我的应用中使用折叠工具栏。按照他们在 Android 开发人员博客上的方式实现后,它似乎无法正常工作。我看到溢出和向上导航按钮,但是当我向下滚动时它们不跟随工具栏。这video这是应该发生的事
我的布局应该是这样的: 有一些问题需要解决: constraintLayout(下周,购物文本)应该位于工具栏底部。 标题文本Next week 滚动完成后可以平滑移动到工具栏中心 水平进度条在con
我似乎无法在我的代码中找到错误。 CollapsingToolbarLayout 没有显示标题,即使我设置了一个。它显示后退按钮但不显示标题,它仍然是普通工具栏的高度。 在工具栏上设置标题或 getS
在我的 MainActivity 中,我有一个 CollapsingToolbarLayout。默认情况下,工具栏是展开的。但我希望它被折叠。因此,正如 StackOverflow 问题中所建议的那样
我有一个触发 CollapsingToolbarLayout 的 RecyclerView,当我尝试在 4.2.2 上重新打开折叠的工具栏时,出现以下崩溃。有什么想法吗? java.lang.Ille
如果有人能给我一些建议来解决我的最新问题,我将不胜感激。 我有一个带有 CollapsingToolbarLayout 的 Activity 。在未折叠状态下,我无法让按钮工作。我不知道如何解决这个问
我将支持设计库的修订版更新到 23.0.1 并得到了这样的行为 - 当侧抽屉重叠时标题消失(抽屉是带有自定义子项的简单 LinearLayout)。没有问题,当我使用 rev. 22.2.1。您对隐藏
在我的应用程序中,我实现了一个包含 Facebook 图片和文本的 CollapsingToolbarLayout,如下图所示: 当图片包含太多白色时,我遇到了一个问题,工具栏 图标保持不可见。 我想
我将 CoordinatorLayout 与 AppBarLayout 和 CollapsingToolbarLayout 一起使用。内容还有一个 NestedScrollView。当我在 Colla
我在带有 RelativeLayout 的 AppBarLayout 中有 CollapsingToolbarLayout
我正在尝试使用我在 CollapsingToolbarLayout 中编写的自定义 View ,但触摸事件似乎无法通过手势检测正确传播到我的自定义 View 。结果是滚动和与 View 的交互无法按预
我是一名优秀的程序员,十分优秀!