DrawerLayout 内的 constraintLayout 内的 RecyclerView 不会滚动
Posted
技术标签:
【中文标题】DrawerLayout 内的 constraintLayout 内的 RecyclerView 不会滚动【英文标题】:RecyclerView inside a constraintLayout inside a drawerLayout will not scroll 【发布时间】:2020-12-23 00:58:58 【问题描述】:不知道还要添加什么。它只是不会滚动,我试了很多次。这是设置:
主活动:
...slimeDrawer.setOnClickListener mainDrawer.openDrawer(ipsDrawer) ...
activity_main 中引用的“ipsDrawer”:
<include
android:id="@+id/ipsDrawer"
layout="@layout/drawer_ips"
android:layout_
android:layout_
android:layout_gravity="left"/>
drawer_ips.xml里面是不会滚动的recyclerView:
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/ipsRecycler"
android:layout_
android:layout_
android:orientation="vertical"
android:clickable="true"
android:focusable="true"
android:scrollbars="vertical"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView17"
app:layout_constraintVertical_bias="0.0" />
为回收站处理东西的类:
class Ips : Fragment()
companion object : LifecycleOwner
fun startIps(activity: Activity, ipsDrawer: View): Ips
val userDatabaseDao = UserDatabase.getInstance(activity.application).userDatabaseDao
val ipsJob = Job()
val ioscope = CoroutineScope(Dispatchers.IO + ipsJob)
val stats = userDatabaseDao.getAllStats()
val ipsAdapter = IpsAdapter()
val ipsRecycler = ipsDrawer.findViewById<RecyclerView>(R.id.ipsRecycler)
ipsRecycler.adapter = ipsAdapter
(ipsRecycler.adapter as IpsAdapter).submitList(stats.value)
stats.observe((activity as AppCompatActivity) as LifecycleOwner, Observer
ipsAdapter.submitList(it)
)
这是完整的activity_main和drawer_ips以及它不滚动的视频:
https://pastebin.com/QYp3i5jz
https://pastebin.com/b3mCC4Cd
https://streamable.com/4v4tlc
如果您需要更多信息,请告诉我
【问题讨论】:
【参考方案1】:在activity_main中我把drawerLayout的最后一个位置移到了,现在它可以工作了
【讨论】:
以上是关于DrawerLayout 内的 constraintLayout 内的 RecyclerView 不会滚动的主要内容,如果未能解决你的问题,请参考以下文章
odoo @api.constrains _sql_constrains
matplotlib 进阶之Constrained Layout Guide