如何消除这两者之间的空白? RecyclerView现在从屏幕的一半开始,从第一个元素到工具栏有空白区域。 (只有当我添加足够的项目时,recyclelerview才会从上面开始)。
我正在使用Kotlin和AnkoLayouts。
override fun createView(ui: AnkoContext<ConnectBleActivity>): View = with(ui) {
return relativeLayout {
lparams(width = matchParent, height = matchParent)
addItemButton = floatingActionButton {
imageResource = android.R.drawable.ic_input_add
}.lparams {
margin = dip(10)
alignParentBottom()
alignParentEnd()
alignParentRight()
gravity = Gravity.BOTTOM or Gravity.END
}
swipeRefreshLayout = swipeRefreshLayout {
rv = recyclerView {
layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true)
adapter = listAdapter
lparams(width = matchParent, height = wrapContent)
}
}.lparams(width = matchParent, height = wrapContent)
}
}
答案 0 :(得分:0)
通过在SwipeRefreshLayout中放置另一个布局解决了这个问题。
swipeRefreshLayout = swipeRefreshLayout {
linearLayout {
rv = recyclerView {
layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true)
adapter = listAdapter
lparams(width = matchParent, height = wrapContent)
}
}
}