停止在CollapsingToolbarLayout上滚动

停止在CollapsingToolbarLayout上滚动

本文介绍了停止在CollapsingToolbarLayout上滚动,使其不会完全折叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个CollapsingToolbarLayout设置,并在其中放置了墙纸.我希望能够阻止它一路崩溃.

I have a CollapsingToolbarLayout setup and im placing a wallpaper there. I want to be able to stop it from collapsing all the way.

我已经尝试过minheight和许多其他事情,但无法弄清楚.

I have tried minheight and many other things but can't figure it out.

我如何才能停止折叠到第二张屏幕截图?

How can i get it to stop collapsing to the second screenshot?

查看加载活动的时间

所需的停车点

当前停止点

推荐答案

CollapsingToolbarLayoutToolbar紧密配合,因此折叠高度取决于工具栏.

CollapsingToolbarLayout works really closely with Toolbar and as such the collapsed height depends on the toolbar.

使用这种布局,我能够解决您的问题(注意:使用Fab和NestedScrollViewRecyclerView进入常规的CoordinatorLayout/AppBarLayout设置):

I was able to solve your problem using this layout (Note it goes into the normal CoordinatorLayout/AppBarLayout Setup, With Fab and a NestedScrollView or RecyclerView):

<android.support.design.widget.CollapsingToolbarLayout
    android:id="@+id/collapsing_toolbar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    app:layout_scrollFlags="scroll|exitUntilCollapsed"
    app:statusBarScrim="?attr/colorPrimaryDark"
    app:contentScrim="@android:color/transparent"
    app:titleEnabled="false"
    >
    <!-- There isnt a contentSCrim attribute so the toolbar is transparent after being
         collapsed
         Disabled the title also as you wont be needing it -->

    <ImageView
        android:id="@+id/image_v"
        android:layout_width="match_parent"
        android:layout_height="360dp"
        android:layout_gravity="center"
        android:scaleType="centerCrop"
        android:src="@drawable/md2"
        android:fitsSystemWindows="true"
        app:layout_collapseMode="parallax"
        tools:ignore="ContentDescription"
        />
        <!-- Normal Imageview. Nothing interesting -->

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="168dp"
        app:layout_collapseMode="pin"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        />
        <!-- The toolbar is styled normally. However we disable the title also in code.
        Toolbar height is the main component that determines the collapsed height -->

    <TextView
        android:text="@string/app_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="?attr/colorPrimaryDark"
        android:paddingLeft="72dp"
        android:paddingRight="0dp"
        android:paddingBottom="24dp"
        android:paddingTop="24dp"
        android:textColor="@android:color/white"
        android:textAppearance="@style/TextAppearance.AppCompat.Headline"
        />
        <!-- The title textView -->

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

相关活动如下:

    ...
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Disable toolbar title
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    ...

这是互动的视频

这篇关于停止在CollapsingToolbarLayout上滚动,使其不会完全折叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:23