Wrap everything in NestedScrollView .....
<android.support.v4.widget.NestedScrollView android:id="@+id/scroll_view" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="none"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <!--ваш контент--> </RelativeLayout> <!--укажите имя вашего пакета до кастомного пейджера--> <yuo.package.ExViewPager android:id="@+id/view_pager_recommendation" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> </android.support.v4.widget.NestedScrollView>
What would the ViewPager be of normal size after creation, specify the size of the hardcode, and if dynamically inherit from the original, and redefine the onMeasure method
public class ExViewPager extends ViewPager { public ExViewPager(Context context) { super(context); } public ExViewPager(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int height = 0; for (int i = 0; i < getChildCount(); i++) { View child = getChildAt(i); child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); int h = child.getMeasuredHeight(); if (h > height) height = h; } heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } }
There is a bug when scrolling "инерция" is lost when RecyclerView is touched, to get rid of this, reassign 2 methods from the LayoutManager
GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 2, LinearLayoutManager.VERTICAL, false){ @Override public boolean canScrollVertically() { return false; } @Override public boolean canScrollHorizontally() { return false; } };
RecyclerViewitself in this way - this is the easiest solution. Or describe in more detail what kind of interaction you want to achieve. - pavlofffFrameLayoutinCollapsingToolbarLayout- Andrey Kasyanov