[英]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.