How can I get full list of the elements including hidden elements by scrolling?

Hi,

I try to find full list of the elements but I have hidden elements so my code doesn’t work correctly:

List<WebElement> elements = driver.findElements(new MobileBy.ByAndroidUIAutomator("new UiSelector().resourceId(\"locator\")"));

I get only visible elements. How can I get full list of the elements including hidden elements by scrolling? I don’t have enough experience :с

Maybe there is some ready-made solution that I don’t know about.

How can anyone predict that your list contain any elements? General answer - NO. Hard solution - scroll an count until elements stop appearing.