AppBarLayout在android 23.0.1中不使用RecyclerView

时间:2016-03-17 08:20:13

标签: android android-recyclerview android-coordinatorlayout android-appbarlayout

使用RecyclerView实现AppBarLayout动画时遇到问题。它不起作用。但如果我用NesterRecyclerView替换RecyclerView,它可以正常工作。请帮我解决这个问题......

        <android.support.design.widget.CoordinatorLayout 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:clickable="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/main.appbar"
    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/main.collapsing"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/Company_Cover_Image"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:scaleType="centerCrop"
            android:src="@drawable/bg"
            android:tint="#11000000"
            app:layout_collapseMode="parallax"
            app:layout_collapseParallaxMultiplier="0.9" />

        <FrameLayout
            android:id="@+id/main.framelayout.title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal"
            android:background="@color/bottom_bar_color"
            android:orientation="vertical"
            android:padding="10dp"
            app:layout_collapseMode="parallax"
            app:layout_collapseParallaxMultiplier="0.3">

            <LinearLayout
                android:id="@+id/main.linearlayout.title"
                android:layout_width="match_parent"
                android:layout_height="65dp"
                android:layout_gravity="center"
                android:gravity="bottom"
                android:orientation="vertical">


                <TextView
                    android:id="@+id/Company_Name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:gravity="bottom|center"
                    android:text="Name"
                    android:textColor="@android:color/white"
                    android:textSize="25sp" />

                <TextView
                    android:id="@+id/Company_Location"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:text="Location"
                    android:textColor="@android:color/white" />

            </LinearLayout>
        </FrameLayout>
    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>


        <android.support.v7.widget.RecyclerView
            android:id="@+id/Company_Detail_Listview"
            android:layout_width="match_parent"
            android:layout_height="400dp"
            android:nestedScrollingEnabled="false"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>

由于

1 个答案:

答案 0 :(得分:0)

使用此布局代码替换布局代码:

<android.support.design.widget.CoordinatorLayout 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:clickable="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/main.appbar"
        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/main.collapsing"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/Company_Cover_Image"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                android:scaleType="centerCrop"
                android:src="@drawable/bg"
                android:tint="#11000000"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.9" />

            <FrameLayout
                android:id="@+id/main.framelayout.title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|center_horizontal"
                android:background="@color/bottom_bar_color"
                android:orientation="vertical"
                android:padding="10dp"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.3">

                <LinearLayout
                    android:id="@+id/main.linearlayout.title"
                    android:layout_width="match_parent"
                    android:layout_height="65dp"
                    android:layout_gravity="center"
                    android:gravity="bottom"
                    android:orientation="vertical">


                    <TextView
                        android:id="@+id/Company_Name"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:gravity="bottom|center"
                        android:text="Name"
                        android:textColor="@android:color/white"
                        android:textSize="25sp" />

                    <TextView
                        android:id="@+id/Company_Location"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:text="Location"
                        android:textColor="@android:color/white" />

                </LinearLayout>
            </FrameLayout>
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <android.support.v7.widget.RecyclerView
            android:id="@+id/Company_Detail_Listview"
            android:layout_width="match_parent"
            android:layout_height="400dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
        <!--android:nestedScrollingEnabled="false"-->

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

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

我希望它有效。