【kotlin】NestedScrollViewで最下部までスクロールした際に処理を実行する
状況
NestedScrollViewで最下部までスクロールした際に処理を実行したい
解決方法
setOnScrollChangeListenerを利用してスクロール位置を検出する
//Fragment
it.scrollView.setOnScrollChangeListener { v, _, scrollY, _, _ ->
it.isScrolled = (v as ViewGroup).getChildAt(0).bottom <= (scrollY + v.height)
}
//xml内にボタンを設置
<data>
<variable
name="isScrolled"
type="Boolean" />
</data>
<TextView
android:id="@+id/button"
android:enabled="@{isScrolled}"/>
拡張関数にすればもっと使いまわせそう。
Author And Source
この問題について(【kotlin】NestedScrollViewで最下部までスクロールした際に処理を実行する), 我々は、より多くの情報をここで見つけました https://qiita.com/narumichi7373/items/12b048162a6cfc761acb著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .