ビューの要素を表示するスクロールビューを実装しています...
このシナリオでは、スクロール ビューからボタンにフォーカスを移したいと考えています。
誰もそれについて考えていますか?
ビューの要素を表示するスクロールビューを実装しています...
このシナリオでは、スクロール ビューからボタンにフォーカスを移したいと考えています。
誰もそれについて考えていますか?
Option I: Using getLocationOnScreen
on all Child Views inside ScrollView
Get instance of scroll view.
ScrollView scrollView = findViewById(R.id.scrollViewID);
Type cast into ViewGroup
ViewGroup viewGroup = (ViewGroup)scrollView;
Find all child views of ViewGroup
( check Android Documentation )
Get rectangle representing location of Child View on screen by calling - getLocationOnScreen
getLocationOnScreen will store x,y coordinates in Rect object, compare rect x,y coordinates to see if Rectangles lies within screen bounds. ( You can get screen by using getLocationOnScreen on Content View / Root View )
Option II: getGlobalVisibleRect
on All child views inside ScrollView
( Quick and Easy )
getGlobalVisibleRect
on each of the child views, if it returns true, it means at-least some of portion of the child view is visible.