我使用回收视图创建了日历。它在模拟器中运行良好,但在实际设备中只加载了很少的元素。
我使用了水平滚动视图,以便一次性加载所有元素,并且我正在为动画的两侧添加填充。
代码片段:
<HorizontalScrollView
android:id="@+id/dateHSV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:scrollbars="none">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/dateRV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:listitem="@layout/rv_item_calender" />
</HorizontalScrollView>
如您所见,在移动设备中仅加载了 3 个日期,而在模拟器 (android 6) 中则加载了所有日期。