I have a Recycler View inside a Viewpager that is inside a NestedScroll View
My layout is as follows
<CoordinatorLayout>
<AppBarLayout>
<CollapsingToolbarLayout>
<Toolbar>
</Toolbar>
</CollapsingToolbarLayout>
</AppBarLayout>
<NestedScrollView>
<ViewPager>
<RecyclerView>
</RecyclerView>
</ViewPager>
</NestedScrollView>
</CoordinatorLayout>
I have more contents inside the RecyclerView but the view is showing items items till the AppBarLayout is being scrolled.
How to make the recycler view scroll complete list?
Below are the screenshots of the View
Edit: Here is the XML
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="128dp">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="128dp"
android:background="@color/colorPrimary">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="128dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="64dp"
android:gravity="center"
android:textSize="32dp"
android:fontFamily="@font/amaranth"
android:text="@string/app_name" />
<EditText
android:id="@+id/search_et"
android:layout_width="match_parent"
android:layout_height="59dp"
android:background="@drawable/rounded_corners"
android:layout_marginRight="14dp"
android:hint="Search"
android:maxLines="1"
android:inputType="text"
android:imeOptions="actionGo"
android:padding="10dp" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_anchor="@id/app_bar_layout"
app:layout_anchorGravity="bottom"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>
<android.support.v7.widget.CardView
app:layout_anchor="@id/nested_scroll_view"
app:layout_anchorGravity="bottom"
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
app:cardElevation="1dp"
app:cardMaxElevation="3dp">
<android.support.design.widget.TabLayout
android:id="@+id/tablayout"
style="@style/MyCustomTabTextAppearance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/whiteColor"
app:tabGravity="fill"
app:tabIndicatorColor="@color/tabBackgroundColor"
app:tabMode="fixed">
</android.support.design.widget.TabLayout>
</android.support.v7.widget.CardView>
</android.support.design.widget.CoordinatorLayout>
Java Code searchResultsRecyclerView = v.findViewById(R.id.search_recycler_view); searchResultsRecyclerView.setNestedScrollingEnabled(false); searchResultsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
searchEditText = getActivity().findViewById(R.id.search_et);
searchEditText.addTextChangedListener(new TextWatcher() {
AsyncTask<Object, Object, Object> asyncTask;
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (asyncTask == null) {
asyncTask = new SearchAsyncTask(editable.toString()).execute();
} else {
asyncTask.cancel(true);
asyncTask = new SearchAsyncTask(editable.toString()).execute();
}
}
});
在setAdapter之前将这一行添加到RecylerView recyclerView.setNestedScrollingEnabled(true);
use recyclerview height wrap_content
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
Add this line in your recycler view xml
android:nestedScrollingEnabled="false"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.