相关疑难解决方法(0)

使用RecyclerView + AppBarLayout

我正在使用新的CoordinatorLayout与AppBarLayout和CollapsingToolbarLayout.在AppBarLayout下面,我有一个带有内容列表的RecyclerView.

我已经验证了当我在列表中上下滚动时,滚动滚动在RecyclerView上工作.但是,我还希望AppBarLayout在扩展期间顺利滚动.

向上滚动以展开CollaspingToolbarLayout时,一旦将手指从屏幕上抬起,滚动会立即停止.如果向上快速向上滚动,有时CollapsingToolbarLayout也会重新折叠.与使用NestedScrollView时,RecyclerView的这种行为似乎有很大不同.

我试图在recyclerview上设置不同的滚动属性,但我无法弄清楚这一点.

这是一个显示一些滚动问题的视频. https://youtu.be/xMLKoJOsTAM

这是一个显示RecyclerView(CheeseDetailActivity)问题的示例. https://github.com/tylerjroach/cheesesquare

以下是使用Chris Banes的NestedScrollView的原始示例. https://github.com/chrisbanes/cheesesquare

android android-appcompat android-layout android-design-library

171
推荐指数
5
解决办法
5万
查看次数

无法滚动AppBarLayout并平滑地折叠工具栏和NestedScrollView

我正在使用我正在使用的一个Android应用程序CoordinatorLayout,AppBarLayoutCollapsingToolbarLayout使用折叠工具栏功能.

NestedScrollView在布局中使用AppBarLayout以相同的布局展开和折叠.当我试图从屏幕中心向上滚动然后它不起作用但是当我尝试从屏幕右上角向上滚动屏幕时它会顺利滚动.

下面提到的是我的xml文件

layout.xml

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:fillViewport="true"
    android:fitsSystemWindows="true"
    android:paddingBottom="2dp"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingTop="5dp"
    android:layout_gravity="fill_vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/fragment_back_color"
            android:orientation="vertical">


            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:padding="5dp">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:background="@drawable/new_recharge" />

                <com.spiceladdoo.views.RobotTextviewRegular
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginLeft="10dp"
                    android:text="NEW PAYMENT"
                    android:textColor="@color/offer_name_text_color" />

            </LinearLayout>


            <RelativeLayout

                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:background="@color/white"
                android:paddingBottom="20dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:paddingTop="20dp">

                <HorizontalScrollView
                    android:id="@+id/hsv"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:fillViewport="true"
                    android:measureAllChildren="false"
                    android:scrollbars="none">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true"
                        android:orientation="horizontal">

                        <LinearLayout …
Run Code Online (Sandbox Code Playgroud)

android android-collapsingtoolbarlayout nestedscrollview

24
推荐指数
3
解决办法
2万
查看次数

NestedScrollView阻止Nougat上的bug(API 25)

我在Nexus 5x(7.1.2)和Google Pixel(7.1.1)上使用NestedScrollView时遇到了一个奇怪的问题.在其他操作系统版本上它运行正常.

举起动画有时会在举起手指后立即停止.它会停滞不前,接下来的几次飞行也可能会停止.为了重现它,你需要上下几次投掷.

在日志中,这些flings在速度,方向等方面看起来几乎相同,所以我找不到这个bug的真正原因.

NestedScrollView并不一定需要的内部CoordinatorLayout,也可以没有NestedScrollingChild在所有.

例如,此错误可以使用以下NestedScrollView子项之一重现:

1)LinearLayout填充TextViews

2) WebView

3)LinearLayout填充RecyclerViews.

我知道RecyclerView内部和行为的可能问题CoordinatorLayout,但它没有关系.所以请不要提及任何

recyclerView.getLayoutManager().setAutoMeasureEnabled(true);
recyclerView.setNestedScrollingEnabled(false);
Run Code Online (Sandbox Code Playgroud)

或类似的东西.

代码示例:

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:text="Put a super long text here"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:text="Put a super long text here"/>

    </LinearLayout>

</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

android scroll android-support-library nestedscrollview android-7.0-nougat

18
推荐指数
1
解决办法
2094
查看次数

使用NestedScrollView,AppBarLayout和CoordinatorLayout平滑滚动和Fling

我正在开发一个应用程序,我正在使用带有CollapsingToolbarLayout和NestedScrollView的AppBarLayout.我已经成功实现了这个并且工作正常.

现在我想要做的是,在Nestedscrollview上进行快速刷卡时,它应该完全滚动到顶部.同样,在向屏幕底部投掷(快速向下滑动)时,它必须顺畅地滚动到底部.但是现在,它只会卡在两者之间,这使它看起来很难看.我已经尝试了许多可用的解决方案,但没有任何方法可以帮助我 我目前的设置如下.

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:zhy="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="RtlHardcoded">

<android.support.design.widget.AppBarLayout
    android:id="@+id/main.appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/main.collapsing"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/placeholder"
            android:layout_width="match_parent"
            android:layout_height="246dp"
            android:scaleType="fitXY"
            android:tint="#11000000"
            app:layout_collapseMode="parallax"
            app:layout_collapseParallaxMultiplier="0.9" />


        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:padding="10dp">


            <FrameLayout
                android:id="@+id/back_frame"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="left|center_vertical"
                android:paddingBottom="5dp"
                android:paddingLeft="5dp"
                android:paddingRight="10dp"
                android:paddingTop="5dp">

                <ImageView
                    android:id="@+id/back_image"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha" />
            </FrameLayout>


            <FrameLayout
                android:id="@+id/frameLayoutheart"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"

                android:layout_gravity="right|center_vertical"
                android:paddingBottom="5dp"
                android:paddingLeft="10dp"
                android:paddingRight="5dp"
                android:paddingTop="5dp">

                <ImageView
                    android:id="@+id/favbtnicon"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:src="@drawable/heart_profile" />
            </FrameLayout>


        </FrameLayout>

        <FrameLayout
            android:id="@+id/main.framelayout.title"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:layout_gravity="bottom|center_horizontal"
            android:orientation="vertical"

            app:layout_collapseMode="parallax"
            app:layout_collapseParallaxMultiplier="0.3">

            <LinearLayout …
Run Code Online (Sandbox Code Playgroud)

android android-collapsingtoolbarlayout android-appbarlayout android-nestedscrollview

17
推荐指数
2
解决办法
1万
查看次数

由于支持lib 26.0.0,因此折叠工具栏会出现故障

自Android支持库从版本25.4.0更新到26.0.0(最高27.0.0)后,我在Collapsing Toolbar内部活动中遇到了一些奇怪的行为.

看看这些GIF的不同之处:

向上滚动时,您会看到折叠工具栏的奇怪反弹.

请参阅以下布局的代码片段:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white_opacity10"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
            app:scrimAnimationDuration="@integer/scrim_animation_short"
            app:titleEnabled="false">

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                app:layout_collapseMode="parallax">

                <!-- Here is layout of header -->

            </FrameLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_gravity="top"
                android:layout_marginBottom="?attr/actionBarSize"
                app:layout_collapseMode="pin"/>

            <android.support.design.widget.TabLayout
                android:id="@+id/tabLayout"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_gravity="bottom"
                app:tabGravity="center"
                app:tabMode="scrollable"
                app:tabSelectedTextColor="@color/white"
                app:tabTextColor="@color/white_inactive"/>

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

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

    <FrameLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </FrameLayout>

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

有人遇到同样的问题吗?这是支持lib bug,还是我做错了什么?

编辑:

android android-coordinatorlayout android-collapsingtoolbarlayout android-appbarlayout

14
推荐指数
1
解决办法
2073
查看次数

单击即可解除Android的CollapsingToolbarLayout

我实现了CollapsingToolbarLayout一个视差视图.

当我在一个连续滚动中向后滚动RecyclerView时,它会展开CollapsingToolbarLayout.

但是当我发出嵌套滚动视图的'fling'时,它会停留在嵌套滚动视图的顶部.你必须再次投掷以解开CollapsingToolbarLayout,

Android Studio 2.0中的ScrollingActivity模板演示了此问题.克里斯贝恩的芝士蛋糕项目在详细视图中也表现出同样的效果.

但是,Google Play和Spotify都不会分别在"查看应用"和"播放列表"视图中显示此问题.在单次投掷中,它们将滚动到嵌套滚动视图的顶部并取消折叠工具栏.

这可能与设计库元素有关吗?

编辑:伊恩已经注意到这个报道的错误.请给它上星并发布你可能有的任何工作.

android android-layout android-design-library android-collapsingtoolbarlayout

6
推荐指数
1
解决办法
1063
查看次数