简体   繁体   English

如何将视图元素粘贴到android中的collapsingtoolbarlayout工具栏下面?

[英]How to stick a view element below a collapsingtoolbarlayout toolbar in android?

trying to build an Android app with a collapsingtoolbarlayout and a view element that always sticks directly below the bottom of the toolbar. 尝试构建一个带有collapsingtoolbarlayout和视图元素的Android应用程序,该视图元素始终直接位于工具栏底部的下方。

I think I'm just messing up my organization within the whole appbarlayout, but I can't seem to figure out the right ordering. 我想我只是在整个appbarlayout中弄乱了我的组织,但我似乎无法弄清楚正确的排序。

Any help would be great! 任何帮助都会很棒! Thanks- 谢谢-

Here's my Activity xml 这是我的Activity xml

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="244dp"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbarLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:collapsedTitleTextAppearance="@style/CollapsedTheme"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleGravity="center|bottom"
            app:expandedTitleMarginBottom="20dp"
            app:expandedTitleMarginEnd="20dp"
            app:expandedTitleMarginStart="20dp"
            app:expandedTitleTextAppearance="@style/ExpandedTheme"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:theme="@style/ToolbarColoredBackArrow">

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

            </LinearLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

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

    <include layout="@layout/content_product" />

And I'm trying to add in 而我正试图加入

    <RelativeLayout
        android:layout_below="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="20dp"
        android:background="@color/blue"/>

So that it always stays below the toolbar, but when the collapsingtoolbarlayout scrolls to the top of the screen, it stays sticking below it. 因此它始终位于工具栏下方,但是当collapsingtoolbarlayout滚动到屏幕顶部时,它会一直停留在屏幕下方。

An AppBarLayout extends LinearLayout - just add your RelativeLayout below your CollapsingToolbarLayout and don't include any layout_scrollFlags . AppBarLayout扩展了LinearLayout - 只需将您的RelativeLayout添加到您的CollapsingToolbarLayout下方,并且不包含任何layout_scrollFlags

<AppBarLayout>
  <CollapsingToolbarLayout />
  <RelativeLayout />
</AppBarLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将RecyclerView放在CollapsingToolbarLayout下面并在Android中折叠时响应工具栏? - How to put RecyclerView below CollapsingToolbarLayout and responsive to toolbar when collapsed in Android? 使用CollapsingToolbarLayout折叠工具栏下方的内容 - Collapse content below toolbar with CollapsingToolbarLayout CollapsingToolbarLayout 在工具栏android上带有图像 - CollapsingToolbarLayout with image on toolbar android 展开后如何将工具栏放置在collapsingtoolbarlayout下方? - How do I place toolbar below collapsingtoolbarlayout when expanded? 带有工具栏和TabLayout的Android CollapsingToolbarLayout - Android CollapsingToolbarLayout with Toolbar and TabLayout 如何在ToolBar下面使用Collapsing ToolBar Layout和TabLayout粘贴Tabs - How to stick Tabs with Collapsing ToolBar Layout and TabLayout below ToolBar 在任何视图android下面粘贴listview的标题 - Stick header of listview below any view android 在Android中的工具栏下方添加视图 - Add View Below Toolbar in android Android工具栏在CollapsingToolbarLayout中重叠TabLayout - Android Toolbar overlapping TabLayout in CollapsingToolbarLayout Android:使用ImageView工具栏背景的CollapsingToolbarLayout - Android: CollapsingToolbarLayout with ImageView Toolbar background
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM