【问题标题】:Overlaying content AppBarLayout using new Material Design使用新的 Material Design 覆盖内容 AppBarLayout
【发布时间】:2015-09-12 07:03:39
【问题描述】:

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

喜欢 Play 商店!五

我的带有 CoordinatorLayout 的 AppBarLayout 和带有 RelativeLayout 的 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: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".....>

如果有人能帮助我,那就太好了。我在互联网上找不到任何东西.. 提前感谢您!

【问题讨论】:

    标签: android android-layout material-design android-toolbar android-coordinatorlayout


    【解决方案1】:

    不难,给你一些伪 XML

    <FrameLayout>
    
        // this is the background part
        <LinearLayout>
           <Top part "blue">
           <Bottom part "white">
        <LinearLayout/>
    
        // here is your main content that overlay the background
        <MainContent margingTop="toolbar_height + something more"/>
    
        // here is the toolbar with no background
        <ToolBar background=@null height="toolbar_height"/>
    <FrameLayout/>
    

    【讨论】:

    • 谢谢,但我想用新的材料设计来实现这一点,如屏幕截图所示。你现在使用 CoordinatorLayout 而不是 Framelayout。
    • 我展示了如何根据截图实现元素的叠加,颜色和阴影只是适当地添加背景。 “主要内容”应该是CardView 等。
    • 一点帮助都没有,也没有回答 OP 的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-10
    • 1970-01-01
    • 1970-01-01
    • 2021-03-14
    • 2015-10-05
    • 1970-01-01
    相关资源
    最近更新 更多