【问题标题】:Recycler View not showing item in Samsung S8回收站视图未在三星 S8 中显示项目
【发布时间】:2018-05-14 10:35:38
【问题描述】:

我在滚动视图中使用recyclerViewGridLayoutManager。这些项目正在适配器中膨胀,但未显示在视图中。此特定问题仅存在于 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 中存在视图问题。

【问题讨论】:

    标签: android android-recyclerview scrollview


    【解决方案1】:

    使用 NestedScrollView 代替 ScrollView

    【讨论】:

      【解决方案2】:

      试试这个

       VideoThumbnailAdapter videoThumbnial = new VideoThumbnailAdapter(activity, this, 
              videoList, videoUrlList, videoTitleList);
                      recyclerView.setHasFixedSize(true);
                      recyclerView.setLayoutManager(new GridLayoutManager(activity),2));
                      recyclerView.setAdapter(videoThumbnial);
      

      【讨论】:

        【解决方案3】:

        如果您不使用类似 isNestedScrollingEnabled 的 java 代码并删除所有额外属性,请尝试这种方式,并在 xml 代码 android:layout_gravity 中删除,因为您提供了 match_parent 和 match_parent。

        recyclerView.setLayoutManager(new GridLayoutManager(this,2,LinearLayoutManager.VERTICAL,false));
        
        recyclerView.setAdapter(videoThumbnailAdapter)
               videoThumbnailAdapter.notifyDataSetChanged();
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2021-03-03
          • 2017-09-17
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-09-11
          • 2015-02-26
          相关资源
          最近更新 更多