java - 水平回收站视图中的不可见项目
问题描述
我正在使用 GridLayoutManager 在水平方向的 recyclerview 中显示一些图像。但是图像在回收站视图中是不可见的。当我在空白处点击时,它会在另一个活动中显示图像,但它们在回收站视图中是不可见的。我试过 VERTICAL 并且它们非常好并且可见。
这是我的片段 xml:
<RelativeLayout>
<ImageView
android:id="@+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:rotation="180"
android:scaleType="centerCrop"
app:srcCompat="@drawable/page_start" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:visibility="visible"
android:layout_height="match_parent" />
</RelativeLayout>
片段.java:
RecyclerView rv;
List<Cards> cardsList;
Context context;
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
context = getActivity();
View rootView = inflater.inflate(R.layout.fragment_cards, container, false);
readJson readJson = new readJson(context);
cardsList = readJson.getcardsList();
rv = rootView.findViewById(R.id.rv);
rv.setLayoutManager(new GridLayoutManager(context, 3, GridLayoutManager.HORIZONTAL, false));
rv.setAdapter(new CardsListAdapter(empty, context));
解决方案
"rv.setLayoutManager(new GridLayoutManager(context, 3, GridLayoutManager.HORIZONTAL, false));"
使用下面的行
rv.setLayoutManager(new GridLayoutManager(context, 3, GridLayoutManager.HORIZONTAL, true));
或者
rv.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, true));
推荐阅读
- angular - 显示额外页面的 ngx 分页
- javascript - discord.js - 检查语音频道中的 DB(分贝)
- warnings - 我们如何自定义 Spartacus 中的默认警告?
- c++ - 有什么办法可以去掉 C++ 程序中整数阶乘的最后一位数字中的“*”
- javascript - 为什么木偶动画比实时运行*快*?
- python-3.x - 这个小小的python程序有什么问题?
- android - 当我在 Android 11 中请求 WRITE_STORAGE 时会发生什么?
- c# - 接受负数的控制台计算器算法
- ckan - 有没有办法可以下载一批只有 Ckan 数据集的新记录
- c++ - 为什么 boost::shared_mutex 不能阻塞超过 128 个线程?