我有一个
RecyclerView
回收视图
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyHolder {
val binding = MyCellBinding.inflate(layoutInflater)
// here, binding.root.layoutParams is null ??
return MyHolder(binding)
}
MyHolder
上课照常
ViewHolder
子类。
这个
MyCellBinding
来自
layout/my_cell.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent" â â
android:layout_height="match_parent" â â
android:padding="8dp">
<TextView android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
...
</LinearLayout>
这个
layout_width/height
上
TextView
正确创建,但由于某些原因,没有
LayoutParams
binding.root
-
LinearLayout
. 因此,当它显示在列表中时,它与
文本框
我可以使用LayoutSpector查看
线性布局
回收视图
.
layout_width
layout_height
线性布局
没有从XML中膨胀?