我有CoordinatorLayout
:
<android.support.design.widget.AppBarLayout
android:id="@+id/appbars"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:orientation="vertical"
app:elevation="0dp">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/_8sdp"
android:layout_marginLeft="@dimen/_2sdp"
android:layout_marginTop="@dimen/_4sdp"
android:paddingLeft="@dimen/_4sdp"
android:paddingRight="@dimen/_4sdp"
android:text="Rating AND Reviews for Burris 4-16x50mm Eliminator III Ballistic Laserscope Riflescope "
android:textColor="@color/black"
android:textSize="@dimen/_16sdp"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed"/>
<com.app.views.recycleview.RecycleView
android:id="@+id/reviews_star_filter_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_4sdp"
android:background="@drawable/solid_white_border_gray_no_padding"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed"/>
<LinearLayout
android:id="@+id/sort_by_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/_4sdp"
android:background="@drawable/solid_white_border_gray_no_padding"
android:orientation="vertical">
<com.app.views.textviews.ReviewsAutoCompleteTextView
android:id="@+id/sort"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="@dimen/_4sdp"
android:background="@drawable/border_gray_solid_gray_nop"
android:clickable="false"
android:cursorVisible="false"
android:dropDownWidth="match_parent"
android:editable="false"
android:gravity="center_vertical"
android:inputType="none"
android:paddingLeft="@dimen/_10sdp"
android:text="test \nMost Helpful"
android:textColor="@color/middle_gray"
android:textSize="12sp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
<View
android:layout_width="match_parent"
android:layout_height="2px"
android:layout_margin="10dp"
android:layout_weight="1.1"
android:background="@color/divider_color_light"/>
<TextView
android:id="@+id/count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Showing 1-40 of 1,465"
android:textColor="@color/middle_gray"/>
<TextView
android:id="@+id/reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/_4sdp"
android:clickable="true"
android:text="@string/reset"
android:textColor="@color/hyper_link"
android:visibility="gone"/>
<View
android:layout_width="match_parent"
android:layout_height="2px"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="@color/divider_color_light"/>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<com.app.opticsplanet.views.recycleview.VerticalRecycleView
android:id="@+id/reviews_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/solid_white_border_gray_no_padding"
android:overScrollMode="never"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
InfinityListener
添加了VerticalRecycleView
。
VerticalRecycleView
有无尽的滚动。它的作品非常完美。
但如果有&lt;列表中的10个项目,无限侦听器被禁用,在这种情况下,我想显示BottomView
。
但是将VerticalRecycleView
重新加工到此容器后会出现问题:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<com.app.opticsplanet.views.recycleview.VerticalRecycleView
android:id="@+id/reviews_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:background="@drawable/solid_white_border_gray_no_padding"
/>
<com.app.opticsplanet.views.BottomView
android:id="@+id/bottom_view"
android:layout_marginTop="@dimen/_8sdp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
此监听器无效:
mReviewsRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy > 0) //check for scroll down
{
visibleItemCount = recyclerView.getChildCount();
totalItemCount = mLayoutManager.getItemCount();
firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
if (loading) {
if (totalItemCount > previousTotal) {
loading = false;
previousTotal = totalItemCount;
}
}
if (!loading && (totalItemCount - visibleItemCount)
<= (firstVisibleItem + visibleThreshold)) {
loading = true;
currentPage++;
loadNewPage(currentPage);
}
}
}
});
如何解决?如果列表中有<10个项目,可能还有其他解决方案如何显示BottomView
答案 0 :(得分:0)
Try using relative layout with parent bottom
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<com.app.opticsplanet.views.recycleview.VerticalRecycleView
android:id="@+id/reviews_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:layout_above="@+id/bottom_view"
android:background="@drawable/solid_white_border_gray_no_padding"
/>
<com.app.opticsplanet.views.BottomView
android:id="@+id/bottom_view"
android:layout_marginTop="@dimen/_8sdp"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="match_parent"
android:visibility="gone"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>