在我的活动XML中,我有一个 Collapsing工具栏,此后,还有一个 ,它引用了我有 NestedScrollView 的其他XML。 这是不折叠时折叠工具栏的图像。
当我向上滚动时,它会折叠起来,并且NestedSrollView看起来像这样:
我希望它只滚动到这样的某个位置,之后用户不能再滚动:
我该如何实现? 这是我的主要XML:
<android.support.design.widget.CoordinatorLayout 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:id="@+id/relLayoutCountryInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_anchor="@+id/testeparadetail"
app:layout_anchorGravity="bottom">
<android.support.design.widget.AppBarLayout
android:id="@+id/testeparadetail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/actionBarDivider"
app:layout_anchor="@+id/testeparadetail"
app:layout_anchorGravity="bottom">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/backgroundcollapsedtoolbardetail"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="exitUntilCollapsed|scroll">
<ImageView
android:id="@+id/imgPhotoDetailFundo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/imgPhotoDetailEscuro"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@drawable/background_pais_info"
android:scaleType="centerInside" />
<ImageView
android:id="@+id/imgEscuroPhotoDetailTopo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cropToPadding="false"
android:scaleX="2"
android:scaleY="-1"
app:srcCompat="@drawable/blur_paises_filtro" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbariddetail"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<com.github.mmin18.widget.RealtimeBlurView
android:id="@+id/blurViewDetail"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:realtimeBlurRadius="10dp"
app:realtimeOverlayColor="#8000" />
<TextView
android:id="@+id/txtNomePaisDetail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="30dp"
android:layout_marginTop="520dp"
android:paddingBottom="40dp"
android:text="TextView"
android:textColor="@android:color/background_light"
android:textSize="35sp"
app:layout_anchor="@+id/txtNomeContinente"
app:layout_anchorGravity="left|bottom" />
<TextView
android:id="@+id/txtDefinicao"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="30dp"
android:layout_marginTop="520dp"
android:paddingBottom="10dp"
android:text="TextView"
android:textColor="@android:color/background_light"
android:textSize="25sp"
app:layout_anchor="@+id/testeparainfo"
app:layout_anchorGravity="left|bottom" />
<ImageView
android:id="@+id/imgVoltarPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
app:srcCompat="@drawable/arrow_back_branca" />
<ImageView
android:id="@+id/imgApagarPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="355dp"
android:layout_marginTop="550dp"
android:paddingBottom="40dp"
app:layout_anchor="@+id/txtDefinicao"
app:layout_anchorGravity="right|bottom"
app:srcCompat="@android:drawable/ic_menu_delete" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include
layout="@layout/content_scrolling_photo_detail"
/>
这是我的收录
<android.support.v4.widget.NestedScrollView 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="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="30dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
答案 0 :(得分:0)
将此行添加到NestedScrollView Child ...请参见下面的代码作为示例...
android:nestedScrollingEnabled="true"
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tablayout"
android:layout_marginTop="2dp"
android:nestedScrollingEnabled="true"/> // add this line to NestedScrollView child
</android.support.v4.widget.NestedScrollView>