使用新的材质设计在AppBarLayout上方叠加内容 [英] Overlaying content above AppBarLayout using new Material Design

本文介绍了使用新的材质设计在AppBarLayout上方叠加内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现类似的目标. (不是FAB或小吃店).如何创建覆盖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商店:

我的带有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.

此外,您应该添加类似的内容

In addition, you should add something like

app:expandedTitleMarginBottom="70dp"

CollapsingToolbarLayout ,因此标题不会出现在叠加的滚动内容下方.

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

这篇关于使用新的材质设计在AppBarLayout上方叠加内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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