I implement scroll view to display element of view...
now in this scenario I want to shift focus from scroll view to button.
does any one have idea about it?
I implement scroll view to display element of view...
now in this scenario I want to shift focus from scroll view to button.
does any one have idea about it?
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.