我正在尝试在具有3列的recyclerview中显示图像...。但是它们不能正确显示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"/>
您可以尝试此解决方案
<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" />