【问题标题】:Images in recyclerView GridLayoutManager are not displaying correctlyrecyclerView GridLayoutManager 中的图像显示不正确
【发布时间】:2020-04-26 18:30:17
【问题描述】:

我正在尝试在 recyclerview 中显示 3 列的图像....但它们没有正确显示 This is the error

recyclerView = view.findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager mLayoutManager = new GridLayoutManager(getContext(), 3);
    recyclerView.setLayoutManager(mLayoutManager);
    postList = new ArrayList<>();
    myFotosAdapter = new MyFotosAdapter(getContext(), postList);
    recyclerView.setAdapter(myFotosAdapter);

这是recyclerview的xml代码

<androidx.recyclerview.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:clipToPadding="false"

            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
            android:id="@+id/recycler_view"/>

【问题讨论】:

    标签: firebase-realtime-database android-recyclerview gridlayoutmanager


    【解决方案1】:

    你能试试这个解决方案吗

             <androidx.recyclerview.widget.RecyclerView
             android:id="@+id/recycler_view"/>
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
    

    app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"

             app:spanCount="3" />
    

    【讨论】:

    • 检查您的行视图 xm 文件
    猜你喜欢
    • 2015-06-01
    • 2020-09-26
    • 2021-03-10
    • 1970-01-01
    • 2016-04-10
    • 2017-12-09
    • 2013-04-25
    • 2021-12-11
    • 1970-01-01
    相关资源
    最近更新 更多