如何在CollapsingToolbarLayout上停止滚动

时间:2016-06-13 09:37:43

标签: android android-layout android-studio android-toolbar android-collapsingtoolbarlayout

我的折叠工具栏布局包含一张图片。我希望在说270dp之前停止滚动图像,然后只滚动剩余的内容。

我已经在Stackoverflow上关注了2个答案,但这似乎对我不起作用。

  1. How to Stop scroll on CollapsingToolbarLayout so it doesn't completely collapse
  2. How to Stop scroll on CollapsingToolbarLayout so it doesn't completely collapse
  3. 布局xml

           <?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="wrap_content"
        android:animateLayoutChanges="true">
    
    
        <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/coordinatorLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <android.support.design.widget.AppBarLayout
                android:id="@+id/app_bar_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    
                <android.support.design.widget.CollapsingToolbarLayout
                    android:id="@+id/collapsing_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:contentScrim="?attr/colorPrimary"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed">
    
    
                    <ImageView
                        android:id="@+id/toolbar_imgview"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="bottom"
                        android:adjustViewBounds="true"
                        android:scaleType="centerCrop"
                        app:layout_collapseMode="parallax" />
    
                    <android.support.v7.widget.Toolbar
    
                        android:id="@+id/toolbar"
                        android:layout_width="match_parent"
                        android:layout_height="?attr/actionBarSize"
                        android:background="@android:color/transparent"
                        app:layout_collapseMode="pin" />
    
                </android.support.design.widget.CollapsingToolbarLayout>
    
            </android.support.design.widget.AppBarLayout>
    
            <android.support.v4.widget.NestedScrollView
                android:id="@+id/nestedscroll"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/app_bar_layout"
                android:background="#ffff"
                app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
                <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">
    
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/toolbar_shadow_height"
                        android:background="@drawable/shape_shadow" />
    
                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="#ffff"
                        android:weightSum="1.0">
    
                        <Button
                            android:layout_width="0dip"
                            android:layout_height="40dp"
                            android:layout_alignParentEnd="true"
                            android:layout_alignParentRight="true"
                            android:layout_alignParentTop="true"
                            android:layout_marginRight="10dp"
                            android:layout_weight=".5"
                            android:background="@drawable/button_bg"
                            android:text="Set Wallpaper"
                            android:textColor="#ff4081"
                            android:textSize="12dp" />
    
                        <Button
                            android:layout_width="0dip"
                            android:layout_height="40dp"
                            android:layout_alignParentLeft="true"
                            android:layout_alignParentStart="true"
                            android:layout_alignParentTop="true"
                            android:layout_weight=".5"
                            android:background="@drawable/button_bg_dw"
                            android:text="Download"
                            android:textColor="#FFFF"
                            android:textSize="12dp" />
    
                    </LinearLayout>
    
    
                    <View
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:background="?attr/dividerHorizontal" />
    
    
                    <include
                        layout="@layout/activity_details"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />
    
    
                </LinearLayout>
    
            </android.support.v4.widget.NestedScrollView>
    
    
        </android.support.design.widget.CoordinatorLayout>
    
    </RelativeLayout>
    

    我已经尝试将AppBarLayout的高度设置为280dp,但没有用。 我正在通过Universal Image Loader设置图像。

0 个答案:

没有答案