Android 使用recyclerview和appbar使视图滚动
如何使一些自定义视图位于Android 使用recyclerview和appbar使视图滚动,android,android-actionbar,android-recyclerview,Android,Android Actionbar,Android Recyclerview,如何使一些自定义视图位于RecyclerView的顶部并与其滚动 -带有视差图像的appbar-向上滚动时折叠 -我的自定义视图-使用回收器移动 -回收视图 我使用nestedscrollview内部的collasingToolBalayout几乎实现了这种行为,但如果内容比屏幕长,则nestedscrollview会切割自定义视图的内容 <android.support.design.widget.CoordinatorLayout xmlns:android="http://s
RecyclerView
的顶部并与其滚动
-带有视差图像的appbar-向上滚动时折叠
-我的自定义视图-使用回收器移动
-回收视图
我使用nestedscrollview
内部的collasingToolBalayout
几乎实现了这种行为,但如果内容比屏幕长,则nestedscrollview
会切割自定义视图的内容
<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:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="ru.example.app.PublicationViewActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white_light"
app:elevation="0dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:collapsedTitleTextAppearance="@android:color/transparent"
app:expandedTitleTextAppearance="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<ImageView
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="@dimen/grid_x_25"
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="@drawable/gradient_action_bar"
app:layout_collapseMode="pin">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="@dimen/grid_x_7"
android:layout_marginLeft="@dimen/grid_x_2">
<TextView
android:id="@+id/toolbar_title"
style="@style/Toolbar.TitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<android.support.v4.widget.NestedScrollView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/grid_x_25"
android:background="@color/white_light">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/content_interests"/>
<View
style="@style/MainDivider"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_gravity="bottom"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</android.support.v7.widget.RecyclerView>
</android.support.design.widget.CoordinatorLayout>
您尝试过LinearLayout
高度asmatch\u parent
?@pRaNaY yes,我尝试过。我试过各种方法。我可以为你的答案找到同样的理由吗@普拉内:谢谢你的回答,但我也试过这种方法。这种情况不是我想要实现的。