LayoutManager-FlowLayout
LayoutManager-FlowLayout copied to clipboard
FlowLayoutManager 不支持 Adapter 根布局的 layout_margin 系列属性
RV 嵌套 RV
BaseViewHolder holder = super.onCreateViewHolder(parent, viewType);
RecyclerView rc = holder.getView(R.id.rc_post);
rc.setLayoutManager(new FlowLayoutManager());
rc.addItemDecoration(new SpaceItemDecoration((int) MetricsUtil.dpToPx(4)));
rc.setAdapter(new LabelAdapter(R.layout.uum_list_item_post));
return holder;
LabelAdapter 内容就一个 TextView
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:background="@drawable/ui_rect_ecf7ff_c2"
android:gravity="center"
android:paddingHorizontal="4dp"
android:paddingVertical="1dp"
android:text="名称,超过6字省略"
android:ellipsize="end"
android:lines="1"
android:maxWidth="80dp"
android:textColor="#00A3C2"
android:textSize="10sp" />
删除 layout_marginEnd 就正常,否则 Adapter 控件会被压缩