布局:
<android.support.v4.widget.NestedScrollView
android:id="@+id/nsv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="已售罄"
android:textColor="#FF333333"
android:textSize="14sp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_sold_out"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
問題:
ViewPager無法翻頁:
NestedScrollView設定
android:fillViewport=”true”
防止卡頓:
LinearLayoutManager manager = new LinearLayoutManager(this);
manager.setOrientation(horizontal);
manager.setSmoothScrollbarEnabled(true);
manager.setAutoMeasureEnabled(true);
rv.setLayoutManager(manager);
rv.setHasFixedSize(true);
rv.setNestedScrollingEnabled(false);
防止位置錯亂:
NestedScrollView的第一個Child設定: