android - How to fix the position of one of the graphics when customizing a ViewGrounp with sliding events?
代言
代言 2017-06-30 09:57:14
0
1
1076

I found that manyViewPagercontrols with indicators inherit aRelativeLayoutand then disguise themselves as aViewPager# through the proxyViewPagermethod. ##, andindicatoris overlaid on thisViewPager.I think this is a bit messy. I wanted to inherit a
ViewPagerand then draw theindicatormyself throughcanvasinonDraw, but I found that I was too young,indicatorWhen drawing, the layout is displayed onitem 0ofViwePager(it looks like it is on top of item 0),ViewPagerWhen slidingindicatoralso ran along.

As shown in the picture above, my

indicatorfollowed. Then I let thex coordinatesof myindicatorbe processed inonDrawusing the ones obtained ingetLocationOnScreen(). It turned out not to work.

In this case, the only thing I can think of is to wrap a layer of

RelativeLayoutoutsideViewPagerlike others, (of course I thinkFrameLayoutis better)

But I am a little reluctant to deal with the control in this way. It cannot be solved with one

Viewbut has to have threeViewnested in each other. I feel uncomfortable. Is there any way to make oneViewGounpWhile processing the sliding content in the control, is certain content not moved at the same time?

Before posting this question, I was thinking, should I monitor the offset of

ViewPagerand thencontinuously move the content in the opposite direction in onDraw? I'll try it

代言
代言

reply all (1)
習慣沉默

I monitoredonScrollChanged()to obtain the offset, and then added this offset inonDraw()to solve the problem.

But I found that theindicatorinonDrawwill be overwritten by the content inViewPager~~ This solution still doesn’t work! ! Help

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!