在scrollView上使用setOnScrollChangeListener动态添加粘性按钮

时间:2018-10-24 03:09:19

标签: kotlin

这样做可行吗?也许通过用setOnScrollChangeListener的scrollY值更新按钮的上边距?

sv.setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY ->

val buttonLayoutParams = button.getLayoutParams() as MarginLayoutParams ;
buttonLayoutParams.topMargin = scrollY ;
button.setLayoutParams(buttonLayoutParams) 

}

0 个答案:

没有答案