I found that manyViewPager
controls with indicators inherit aRelativeLayout
and then disguise themselves as aViewPager# through the proxy
ViewPagermethod. ##, and
indicatoris overlaid on this
ViewPager.
I think this is a bit messy. I wanted to inherit a
ViewPagerand then draw the
indicatormyself through
canvasin
onDraw, but I found that I was too young,
indicatorWhen drawing, the layout is displayed on
item 0of
ViwePager(it looks like it is on top of item 0),
ViewPagerWhen sliding
indicatoralso ran along.
As shown in the picture above, my
indicatorfollowed. Then I let the
x coordinatesof my
indicatorbe processed in
onDrawusing the ones obtained in
getLocationOnScreen(). It turned out not to work.
RelativeLayoutoutside
ViewPagerlike others, (of course I think
FrameLayoutis better)
Viewbut has to have three
Viewnested in each other. I feel uncomfortable. Is there any way to make one
ViewGounpWhile processing the sliding content in the control, is certain content not moved at the same time?
ViewPagerand then
continuously move the content in the opposite direction in onDraw? I'll try it
I monitored
onScrollChanged()
to obtain the offset, and then added this offset inonDraw()
to solve the problem.But I found that the
indicator
inonDraw
will be overwritten by the content inViewPager
~~ This solution still doesn’t work! ! Help