我在滚动视图中使用recyclerView
和GridLayoutManager
。这些项目在适配器中充气但未显示在视图中。此特定问题仅限于 Samsung S8 。休息所有设备都正确显示它。
val layoutManager = GridLayoutManager(activity, 2)
layoutManager.orientation = GridLayoutManager.VERTICAL
val recyclerView = rvDropDownVideos
val videoThumbnailAdapter = VideoThumbnailAdapter(activity, this,
videoList, videoUrlList, videoTitleList)
recyclerView.layoutManager = layoutManager
recyclerView.isNestedScrollingEnabled = false
recyclerView.adapter = videoThumbnailAdapter
XML代码是
<android.support.v7.widget.RecyclerView
android:id="@+id/rvDropDownVideos"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@drawable/rounded_corners_bottom"
android:padding="@dimen/dp_10" />
任何人都可以告诉我为什么在S8中有观点问题。
答案 0 :(得分:2)
使用 NestedScrollView 代替 ScrollView 。
答案 1 :(得分:0)
尝试使用此
VideoThumbnailAdapter videoThumbnial = new VideoThumbnailAdapter(activity, this,
videoList, videoUrlList, videoTitleList);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new GridLayoutManager(activity),2));
recyclerView.setAdapter(videoThumbnial);
答案 2 :(得分:0)
尝试这种方式java代码并删除所有额外的属性,如果你不使用像isNestedScrollingEnabled,并删除xml代码android:layout_gravity,因为你给match_parent和match_parent。
recyclerView.setLayoutManager(new GridLayoutManager(this,2,LinearLayoutManager.VERTICAL,false));
recyclerView.setAdapter(videoThumbnailAdapter)
videoThumbnailAdapter.notifyDataSetChanged();