From Newsgroup: comp.mobile.android
Jakub <
jak74@interia.pl> wrote or quoted:
how to get button max position at recylcerView
at java or kotlin
| Here is how to reword your question into clear, professional English:
|
| Option 1 (Direct and natural):
|
| "How do I find the maximum scroll position of a button inside a
| RecyclerView using Java or Kotlin?"
|
| Option 2 (Short and technical):
|
| "How to get the maximum scroll position for a button in a RecyclerView
| (Java/Kotlin)?"
|
| Quick Technical Solutions
|
| Depending on what you mean by "max position," here are the two most
| common solutions:
|
| 1. Find the last visible item position
|
| If you want to know when the user scrolls to the very bottom where a
| button might be hidden, use the layout manager.
|
| Kotlin:
|
| val layoutManager = recyclerView.layoutManager as
| LinearLayoutManagerval maxPosition =
| layoutManager.findLastVisibleItemPosition()
|
| Java:
|
| LinearLayoutManager layoutManager = (LinearLayoutManager)
| recyclerView.getLayoutManager();int maxPosition =
| layoutManager.findLastVisibleItemPosition();
|
| 2. Find the exact X/Y coordinates of a button
|
| If you need the visual pixel position of a specific button inside a
| row, use getLocationOnScreen.
|
| Kotlin:
|
| val location = IntArray(2)
|
| myButton.getLocationOnScreen(location)val x = locationval y = location
--- Synchronet 3.22a-Linux NewsLink 1.2