UiScrollable is a UiCollection and provides support for searching
for items in scrollable layout elements. This class can be used with
horizontally or vertically scrollable controls.
Performs a two-pointer gesture, where each pointer moves diagonally
opposite across the other, from the center out towards the edges of the
this UiObject.
UiSelector: a UiSelector selector to identify the scrollable
layout element.
Public methods
flingBackward
boolean flingBackward ()
Performs a backwards fling action with the default number of fling
steps (5). If the swipe direction is set to vertical,
then the swipe will be performed from top to bottom. If the swipe
direction is set to horizontal, then the swipes will be performed from
left to right. Make sure to take into account devices configured with
right-to-left languages like Arabic and Hebrew.
Returns
boolean
true if scrolled, and false if can't scroll anymore
Performs a forward fling with the default number of fling steps (5).
If the swipe direction is set to vertical, then the swipes will be
performed from bottom to top. If the swipe
direction is set to horizontal, then the swipes will be performed from
right to left. Make sure to take into account devices configured with
right-to-left languages like Arabic and Hebrew.
Performs a fling gesture to reach the beginning of a scrollable layout element.
The beginning can be at the top-most edge in the case of vertical controls, or
the left-most edge for horizontal controls. Make sure to take into
account devices configured with right-to-left languages like Arabic and Hebrew.
Performs a fling gesture to reach the end of a scrollable layout element.
The end can be at the bottom-most edge in the case of vertical controls, or
the right-most edge for horizontal controls. Make sure to take into
account devices configured with right-to-left languages like Arabic and Hebrew.
Searches for a child element in the present scrollable container.
The search first looks for a child element that matches the selector
you provided, then looks for the content-description in its children elements.
If both search conditions are fulfilled, the method returns a {@ link UiObject}
representing the element matching the selector (not the child element in its
subhierarchy containing the content-description). By default, this method performs a
scroll search.
See getChildByDescription(UiSelector, String, boolean)
Parameters
childPattern
UiSelector: UiSelector for a child in a scollable layout element
text
String: Content-description to find in the children of
the childPattern match
Searches for a child element in the present scrollable container.
The search first looks for a child element that matches the selector
you provided, then looks for the content-description in its children elements.
If both search conditions are fulfilled, the method returns a {@ link UiObject}
representing the element matching the selector (not the child element in its
subhierarchy containing the content-description).
Parameters
childPattern
UiSelector: UiSelector for a child in a scollable layout element
text
String: Content-description to find in the children of
the childPattern match (may be a partial match)
Searches for a child element in the present scrollable container that
matches the selector you provided. The search is performed without
scrolling and only on visible elements.
Parameters
childPattern
UiSelector: UiSelector for a child in a scollable layout element
instance
int: int number representing the occurance of
a childPattern match
Searches for a child element in the present scrollable container. The
search first looks for a child element that matches the
selector you provided, then looks for the text in its children elements.
If both search conditions are fulfilled, the method returns a {@ link UiObject}
representing the element matching the selector (not the child element in its
subhierarchy containing the text).
Parameters
childPattern
UiSelector: UiSelector selector for a child in a scrollable layout element
text
String: String to find in the children of the childPattern match
Searches for a child element in the present scrollable
container. The search first looks for a child element that matches the
selector you provided, then looks for the text in its children elements.
If both search conditions are fulfilled, the method returns a {@ link UiObject}
representing the element matching the selector (not the child element in its
subhierarchy containing the text). By default, this method performs a
scroll search.
See getChildByText(UiSelector, String, boolean)
Parameters
childPattern
UiSelector: UiSelector selector for a child in a scrollable layout element
text
String: String to find in the children of the childPattern match
max the number of search swipes to perform until giving up
getSwipeDeadZonePercentage
double getSwipeDeadZonePercentage ()
Returns the percentage of a widget's size that's considered as a no-touch
zone when swiping. The no-touch zone is set as a percentage of a widget's total
width or height, denoting a margin around the swipable area of the widget.
Swipes must start and end inside this margin. This is important when the
widget being swiped may not respond to the swipe if started at a point
too near to the edge. The default is 10% from either edge.
Returns
double
a value between 0 and 1
scrollBackward
boolean scrollBackward (int steps)
Performs a backward scroll. If the swipe direction is set to vertical,
then the swipes will be performed from top to bottom. If the swipe
direction is set to horizontal, then the swipes will be performed from
left to right. Make sure to take into account devices configured with
right-to-left languages like Arabic and Hebrew.
Parameters
steps
int: number of steps. Use this to control the speed of the scroll action.
Performs a backward scroll with the default number of scroll steps (55).
If the swipe direction is set to vertical,
then the swipes will be performed from top to bottom. If the swipe
direction is set to horizontal, then the swipes will be performed from
left to right. Make sure to take into account devices configured with
right-to-left languages like Arabic and Hebrew.
Returns
boolean
true if scrolled, and false if can't scroll anymore
Performs a forward scroll action on the scrollable layout element until
the content-description is found, or until swipe attempts have been exhausted.
See setMaxSearchSwipes(int)
Parameters
text
String: content-description to find within the contents of this scrollable layout element.
Performs a forward scroll. If the swipe direction is set to vertical,
then the swipes will be performed from bottom to top. If the swipe
direction is set to horizontal, then the swipes will be performed from
right to left. Make sure to take into account devices configured with
right-to-left languages like Arabic and Hebrew.
Parameters
steps
int: number of steps. Use this to control the speed of the scroll action
Performs a forward scroll with the default number of scroll steps (55).
If the swipe direction is set to vertical,
then the swipes will be performed from bottom to top. If the swipe
direction is set to horizontal, then the swipes will be performed from
right to left. Make sure to take into account devices configured with
right-to-left languages like Arabic and Hebrew.
Performs a forward scroll action on the scrollable layout element until
the text you provided is visible, or until swipe attempts have been exhausted.
See setMaxSearchSwipes(int)
Scrolls to the beginning of a scrollable layout element. The beginning
can be at the top-most edge in the case of vertical controls, or the
left-most edge for horizontal controls. Make sure to take into account
devices configured with right-to-left languages like Arabic and Hebrew.
boolean scrollToBeginning (int maxSwipes,
int steps)
Scrolls to the beginning of a scrollable layout element. The beginning
can be at the top-most edge in the case of vertical controls, or the
left-most edge for horizontal controls. Make sure to take into account
devices configured with right-to-left languages like Arabic and Hebrew.
Parameters
maxSwipes
int
steps
int: use steps to control the speed, so that it may be a scroll, or fling
Scrolls to the end of a scrollable layout element. The end can be at the
bottom-most edge in the case of vertical controls, or the right-most edge for
horizontal controls. Make sure to take into account devices configured with
right-to-left languages like Arabic and Hebrew.
Scrolls to the end of a scrollable layout element. The end can be at the
bottom-most edge in the case of vertical controls, or the right-most edge for
horizontal controls. Make sure to take into account devices configured with
right-to-left languages like Arabic and Hebrew.
Parameters
maxSwipes
int
steps
int: use steps to control the speed, so that it may be a scroll, or fling
Sets the percentage of a widget's size that's considered as no-touch
zone when swiping.
The no-touch zone is set as percentage of a widget's total width or height,
denoting a margin around the swipable area of the widget. Swipes must
always start and end inside this margin. This is important when the
widget being swiped may not respond to the swipe if started at a point
too near to the edge. The default is 10% from either edge.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-11 UTC."],[],[]]