Как узнать элементы, которые полностью видны в окне просмотра ленивой строки в компоновке реактивного ранца?Android

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 Как узнать элементы, которые полностью видны в окне просмотра ленивой строки в компоновке реактивного ранца?

Сообщение Anonymous »


I have a lazy row that contains items. Now I want to make an API call for the items which are fully visible in the viewport whenever the user scrolls the lazy row.

I have tried the following code:

listState = rememberLazyListState() LaunchedEffect(listState){ snapshotFlow { listState.firstVisibleItemIndex } .collectLatest{ Log.d("printed Item", listState.firstVisibleItemIndex.toString()) }} The problems with this code are:
  • Even though the 2nd item occupies the viewport, it will not be printed unless the 1st item is fully invisible.
  • For the tablets, due to their large screen sizes, only the API call is made for the first visible item even though there are 2 visible items on the screen. Please refer to the screenshots.

When the first item is partially visible and 2nd item is fully visible [1]: Изображение

When the 2nd tile is fully visible and the first tile is completely invisible [2]: Изображение

For the tablets where 2 items are completely visible [3]: Изображение

Can anyone please tell me how to resolve my issue?


Источник: https://stackoverflow.com/questions/724 ... ow-in-jetp
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Android»