【发布时间】:2016-05-24 07:47:45
【问题描述】:
我正在设置折叠工具栏布局。我已经为工具栏下方的相对布局设置了视差模式。
但是当我向上滚动工具栏时它不会褪色。我只是在工具栏标题上方显示相对布局。它与工具栏合并。
已设置所有模式,但它仍在合并。
布局:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="160dp"
android:id="@+id/appbar"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="false">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"/>
<RelativeLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
app:layout_collapseMode="parallax"
android:layout_gravity="bottom"
android:layout_marginBottom="10dp"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">
<TextView
android:id="@+id/eventName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Event Name"
android:textColor="#ffffff"
android:textSize="14sp"/>
<TextView
android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/eventName"
android:layout_marginTop="10dp"
android:text="Date"
android:textColor="#ffffff"
android:textSize="14sp"/>
<TextView
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/date"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:text="Time"
android:textColor="#ffffff"
android:textSize="14sp"/>
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="false"
android:layout_below="@+id/textView6"
android:layout_marginTop="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PLAN"
android:layout_centerHorizontal="true"
android:textAppearance="@android:style/TextAppearance.Large"
android:id="@+id/textView6"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="150dp"
android:layout_height="40dp"
style="?android:attr/borderlessButtonStyle"
android:text="Schedule"
android:id="@+id/schedule"
android:layout_gravity="center_horizontal"
android:background="@drawable/list_background"
android:layout_marginTop="20dp" />
<Button
android:layout_width="150dp"
android:layout_height="40dp"
style="?android:attr/borderlessButtonStyle"
android:text="Check List"
android:id="@+id/button4"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="@drawable/list_background" />
<Button
android:layout_width="150dp"
android:layout_height="40dp"
android:text="Vendors"
style="?android:attr/borderlessButtonStyle"
android:id="@+id/button5"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="@drawable/list_background" />
<Button
android:layout_width="150dp"
android:layout_height="40dp"
android:text="Invitee"
style="?android:attr/borderlessButtonStyle"
android:id="@+id/button6"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="@drawable/list_background" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
向上滚动后看起来像这样:
怎么了?
请帮忙谢谢..
【问题讨论】:
-
添加 CoordinatorLayout 作为你的父布局。
-
你能分享屏幕吗?
-
我已将协调器布局添加为父布局,不知道为什么它没有发布@PiyushGupta
-
请检查添加的屏幕。 @jaydroider
标签: android android-layout parallax android-collapsingtoolbarlayout