1

我已经CollapsingToolbarLayout成功完成了,但我有疑问。当我在内容上执行滚动事件时,除了CollapsingToolbarLayout它的内容效果很好,但是当我在它的内容上执行滚动事件时CollapsingToolbarLayout它不起作用。是限制还是我错过了什么..请告诉我哪里出错了..

以下是我的 XML:

<?xml version="1.0" encoding="utf-8"?>

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

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar_profile"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        android:fitsSystemWindows="true"
        android:minHeight="?attr/actionBarSize"
        app:contentScrim="@android:color/transparent"
        app:expandedTitleMarginStart="5dp"
        app:expandedTitleTextAppearance="@android:color/transparent"

    app:layout_behavior="@string/appbar_scrolling_view_behavior"
        app:statusBarScrim="@android:color/black" >

        <LinearLayout
            android:id="@+id/linearLayout_profile_container_bpl"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/cardview_profile"
            android:layout_marginTop="@dimen/thumb_image_size_one"
            android:gravity="center_horizontal"
            android:orientation="vertical" >

            <RelativeLayout
                android:layout_width="@dimen/Layout_height_width"
                android:layout_height="@dimen/Layout_height_width" >

                <RelativeLayout
                    android:id="@+id/relative_profile_imageview_container_bpl"
                    android:layout_width="@dimen/thumb_image_size"
                    android:layout_height="@dimen/thumb_image_size"
                    android:layout_centerInParent="true"
                    android:background="@drawable/rounded_corner_with_dark_orange_background_one" >

                    <com.oi.example.roundedimageview.SelectableRoundedImageView
                        android:id="@+id/imageView_profile_bpl"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_centerInParent="true"
                        android:contentDescription="@string/app_name"
                        app:sriv_left_bottom_corner_radius="@dimen/corner_radius_for_option"
                        app:sriv_left_top_corner_radius="@dimen/corner_radius_for_option"
                        app:sriv_right_bottom_corner_radius="@dimen/corner_radius_for_option"
                        app:sriv_right_top_corner_radius="@dimen/corner_radius_for_option" />

                    <TextView
                        android:id="@+id/textView_profile_pic_bpl"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:contentDescription="@string/app_name"
                        android:gravity="center"
                        android:textColor="@color/color_dark_orange"
                        android:textSize="@dimen/Initial"
                        android:visibility="gone" />
                </RelativeLayout>

                <ImageView
                    android:id="@+id/textview_level_bpl"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentTop="true"
                    android:contentDescription="@string/app_name"
                    android:visibility="visible" />
            </RelativeLayout>

            <TextView
                android:id="@+id/textView_name_bpl"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/margin_small_one"
                android:layout_marginRight="@dimen/margin_small_one"
                android:gravity="center"
                android:textColor="@android:color/black"
                android:textSize="@dimen/title"
                android:textStyle="bold" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/margin_small"
                android:gravity="center_horizontal"
                android:orientation="horizontal" >

                <LinearLayout
                    android:id="@+id/linearLayout_followers_bpl"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center_horizontal"
                    android:orientation="vertical" >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/string_followeres"
                        android:textColor="@color/color_light_grey"
                        android:textSize="@dimen/subhead" />

                    <TextView
                        android:id="@+id/textview_followers_bpl"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin_small_two"
                        android:textColor="@color/color_light_grey"
                        android:textSize="@dimen/subhead" />
                </LinearLayout>

                <View
                    android:layout_width="0.5dp"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center_vertical"
                    android:layout_margin="@dimen/margin_small"
                    android:background="@color/color_light_grey" />

                <LinearLayout
                    android:id="@+id/linearLayout_following_bpl"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center_horizontal"
                    android:orientation="vertical" >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/string_following"
                        android:textColor="@color/color_light_grey"
                        android:textSize="@dimen/subhead" />

                    <TextView
                        android:id="@+id/textview_following_bpl"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="@dimen/margin_small_two"
                        android:textColor="@color/color_light_grey"
                        android:textSize="@dimen/subhead" />
                </LinearLayout>
            </LinearLayout>

            <TextView
                android:id="@+id/textView_aboutMe_bpl"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/margin_small_one"
                android:layout_marginRight="@dimen/margin_small_one"
                android:layout_marginTop="@dimen/margin_small"
                android:gravity="center"
                android:textColor="@color/color_light_grey"
                android:textSize="@dimen/subhead" />

        </LinearLayout>

        <include
            android:id="@+id/toolbar_profile"
            layout="@layout/toolbar_with_card_as_bg" />
    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:orientation="vertical" >

    <com.oi.example.SlidingTabLayout
        android:id="@+id/tab_layout_profile"
        style="@style/AppTabLayoutProfile"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:minHeight="?attr/actionBarSize" />

    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager_profile"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginBottom="@dimen/margin_small"
        android:layout_marginLeft="@dimen/margin_small_one"
        android:layout_marginRight="@dimen/margin_small_one"
        android:layout_marginTop="@dimen/margin_small"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>

4

1 回答 1

0

我通过使用解决了它NestedScrollView,将整个内容CollapsingToolbarLayout放入其中。紧随其后的是最终的 XML:

<?xml version="1.0" encoding="utf-8"?>

    <RelativeLayout
        android:layout_width="@dimen/Layout_height_width"
        android:layout_height="@dimen/Layout_height_width" >

        <RelativeLayout
            android:id="@+id/relative_profile_imageview_container_bpl"
            android:layout_width="@dimen/thumb_image_size"
            android:layout_height="@dimen/thumb_image_size"
            android:layout_centerInParent="true"
            android:background="@drawable/rounded_corner_with_dark_orange_background_one" >

            <com.oi.example.roundedimageview.SelectableRoundedImageView
                android:id="@+id/imageView_profile_bpl"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_centerInParent="true"
                android:contentDescription="@string/app_name"
                app:sriv_left_bottom_corner_radius="@dimen/corner_radius_for_option"
                app:sriv_left_top_corner_radius="@dimen/corner_radius_for_option"
                app:sriv_right_bottom_corner_radius="@dimen/corner_radius_for_option"
                app:sriv_right_top_corner_radius="@dimen/corner_radius_for_option" />

            <TextView
                android:id="@+id/textView_profile_pic_bpl"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:contentDescription="@string/app_name"
                android:gravity="center"
                android:textColor="@color/color_dark_orange"
                android:textSize="@dimen/Initial"
                android:visibility="gone" />
        </RelativeLayout>

        <ImageView
            android:id="@+id/textview_level_bpl"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:contentDescription="@string/app_name"
            android:visibility="visible" />
    </RelativeLayout>

    <TextView
        android:id="@+id/textView_name_bpl"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/margin_small_one"
        android:layout_marginRight="@dimen/margin_small_one"
        android:gravity="center"
        android:textColor="@android:color/black"
        android:textSize="@dimen/title"
        android:textStyle="bold" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/margin_small"
        android:gravity="center_horizontal"
        android:orientation="horizontal" >

        <LinearLayout
            android:id="@+id/linearLayout_followers_bpl"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="vertical" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/string_followeres"
                android:textColor="@color/color_light_grey"
                android:textSize="@dimen/subhead" />

            <TextView
                android:id="@+id/textview_followers_bpl"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/margin_small_two"
                android:textColor="@color/color_light_grey"
                android:textSize="@dimen/subhead" />
        </LinearLayout>

        <View
            android:layout_width="0.5dp"
            android:layout_height="fill_parent"
            android:layout_gravity="center_vertical"
            android:layout_margin="@dimen/margin_small"
            android:background="@color/color_light_grey" />

        <LinearLayout
            android:id="@+id/linearLayout_following_bpl"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="vertical" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/string_following"
                android:textColor="@color/color_light_grey"
                android:textSize="@dimen/subhead" />

            <TextView
                android:id="@+id/textview_following_bpl"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/margin_small_two"
                android:textColor="@color/color_light_grey"
                android:textSize="@dimen/subhead" />
        </LinearLayout>
    </LinearLayout>

    <TextView
        android:id="@+id/textView_aboutMe_bpl"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/margin_small_one"
        android:layout_marginRight="@dimen/margin_small_one"
        android:layout_marginTop="@dimen/margin_small"
        android:gravity="center"
        android:textColor="@color/color_light_grey"
        android:textSize="@dimen/subhead" />

</LinearLayout>

于 2015-09-03T04:26:37.897 回答