使用新的 Material Design 将内容覆盖在 AppBarLayout 之上 [英] Overlaying content above AppBarLayout using new Material Design

查看:24
本文介绍了使用新的 Material Design 将内容覆盖在 AppBarLayout 之上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现这样的目标.(不是 FAB 或 Snackbar).如何创建布局,覆盖 AppBarLayout?像这样!(例如)

I want to achieve something like that. (not the FAB or the Snackbar). How can i create a layout, overlaying the AppBarLayout? Like this! (For Example)

喜欢 Play 商店:

Like Play Store:

我的带有 CoordinatorLayout 的 AppBarLayout 和带有 RelativeLayout 的 NestedScrollView 作为内容看起来像这样:

My AppBarLayout with CoordinatorLayout and NestedScrollView with RelativeLayout as content looks like this:

<android.support.design.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/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="@dimen/_118sdp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsingToolbarLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:contentScrim="@color/mpc_pink"
        app:expandedTitleMarginStart="@dimen/_40sdp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <de.mypostcardstore.widgets.ItemImageView
            android:id="@+id/header"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:src="@color/mpc_pink"
            app:layout_collapseMode="parallax"
            app:layout_collapseParallaxMultiplier="0.7" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/article_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:minHeight="?attr/actionBarSize"
            app:contentScrim="@color/mpc_pink"
            app:layout_collapseMode="pin"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />


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

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

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="?android:colorBackground"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

如果有人能帮我一下就好了.我在互联网上找不到任何东西...

It would be awesome if someone could help me out. I can not find anything on the internet...

提前致谢!

推荐答案

添加类似的东西

app:behavior_overlapTop="64dp"

到您的 NestedScrollView,它将被放置在展开的工具栏上方.

to your NestedScrollView and it will be placed above the expanded toolbar.

另外,你应该添加类似

app:expandedTitleMarginBottom="70dp"

到您的 CollapsingToolbarLayout,这样标题就不会出现在您重叠的滚动内容下.

to your CollapsingToolbarLayout so the title does not appear under your overlaid scroll content.

这篇关于使用新的 Material Design 将内容覆盖在 AppBarLayout 之上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆