Android – collapsingtoolbarlayout set animation threshold?
•
Android
In my application, when I start scrolling the layout, collapsing toolbar layout almost immediately starts changing the background to the rag color I set
Is there any way to set the collapsing toolbar to start changing the value of the background?
This is my XML layout:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="eu.ericnisoli.ambrosettiap.activities.MeetingActivity"
android:visibility="visible"
android:id="@+id/container">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:fitsSystemWindows="true"
android:layout_height="@dimen/app_bar_height"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
app:titleEnabled="false">
<RelativeLayout
android:id="@+id/relativeLayout_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
app:layout_collapseMode="parallax">
<FrameLayout
android:id="@+id/frameLayout_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/frameLayout_info">
<ImageView
android:id="@+id/imageView_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/login_bg"
android:scaleType="centerCrop"/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/detail_meeting_gradient" />
<LinearLayout
android:id="@+id/linearLayout_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingEnd="80dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:layout_gravity="bottom">
<TextView
android:id="@+id/textView_meeting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/meeting"
android:textColor="@color/text_grey_1"
android:textSize="@dimen/text_size_14"
android:textAllCaps="true"
/>
<TextView
android:id="@+id/textView_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="@dimen/text_size_16"
android:text="New Text"
/>
</LinearLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/frameLayout_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/grey_2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="32dp"
android:paddingBottom="32dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pin_small_icon"
android:layout_marginBottom="4dp"/>
<TextView
android:id="@+id/textView_place"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_black_1"/>
<TextView
android:id="@+id/textView_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_black_1"/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="32dp"
android:paddingBottom="32dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/cal_small_icon"
android:layout_marginBottom="4dp"/>
<TextView
android:id="@+id/textView_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_black_1"/>
<TextView
android:id="@+id/textView_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_black_1"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="@string/event_caps"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:layout_anchor="@+id/app_bar"
app:layout_anchorGravity="bottom"
app:layout_collapseMode="pin">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
app:layout_anchor="@+id/app_bar"
app:layout_anchorGravity="bottom"
android:background="@color/grey_2"
app:tabTextColor="@color/text_black_1"
app:tabSelectedTextColor="@color/text_black_1"
style="@style/DetailTab"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@drawable/shadow"
android:layout_gravity="bottom"/>
</FrameLayout>
<android.support.v4.view.ViewPager
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_marginTop="?attr/actionBarSize"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@id/frameLayout_title"
app:layout_anchorGravity="bottom|end"/>
</android.support.design.widget.CoordinatorLayout>
<ProgressBar
android:id="@+id/progress"
android:layout_width="48dp"
android:layout_height="48dp"
android:indeterminate="true"
android:layout_gravity="center"
android:visibility="gone"/>
</FrameLayout>
resolvent:
For version 26.1 or later, you can use the scriptvisiblehighghttrigger property to set the height threshold when the rag overlay is displayed
<android.support.design.widget.CollapsingToolbarLayout
app:scrimVisibleHeightTrigger="80dp"
...>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码