以编程方式滚动NestedScrollView不会为ActionBar设置动画

时间:2019-10-15 09:08:43

标签: android android-scrollview android-nestedscrollview

当用户在ConstraintLayout中滚动时,我正在使用ActionBar来隐藏NestedScrollView。我来自here

这很神奇,但是...单击滚动菜单时,我在滚动视图的底部有一个Back to Top按钮,称为.scrollTo(0,0)。问题在于,ActionBar不会在视图中不显示动画。

如何触发它后退?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    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:orientation="vertical">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar_offer_details"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_scrollFlags="scroll|enterAlways|snap" />

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

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/layout_offer_detail_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorBackground"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

               // .................

               <!--BACK TO TOP-->
               <TextView
                android:id="@+id/tvBackToTop"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/containerSections"
                android:layout_alignParentRight="true"
                android:drawableRight="@drawable/ic_back_to_top"
                android:drawablePadding="5dp"
                android:gravity="center_vertical"
                android:paddingLeft="@dimen/form_margin"
                android:paddingTop="@dimen/field_margin"
                android:paddingRight="@dimen/form_margin"
                android:paddingBottom="@dimen/form_margin"
                android:text="@string/offer_details_back_to_top"
                android:textSize="16sp"
                android:textStyle="bold"
                android:visibility="gone" />

            </RelativeLayout>

        </android.support.v4.widget.NestedScrollView>

    </android.support.design.widget.CoordinatorLayout>

    <ie.xxxx.xxxx.controls.ProgressView
        android:id="@+id/layout_progress"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>

0 个答案:

没有答案