I have a HorizontalScrollView
containing a LinearLayout
, which in turn contains a couple of FrameLayout
s. Each FrameLayout
contains the layout of a Fragment
. Now I'm trying to get the view, i.e. FrameLayout
, which is currently visible or in focus within the HorizontalScrollView
. As soon as I have the view in focus I could get it's index within the LinearLayout
.
I've tried the following, but nothing works:
- HorizontalScrollView.findFocus() - returns null
- LinearLayout.findFocus() - returns null
- LinearLayout.getFocusedChild() - returns null
- FrameLayout.hasFocus() - returns false for all
FrameLayout
s
I could also try to figure out which child of the LinearLayout
has focus, by doing calculations based on current X-position of each child. However, calling getX()
on each child always returns "0.0".
Does anyone have an idea how to get the view in focus (or even better it's index within the LinearLayout
)?