Ok, the question may sound confusing. Let me explain the scenario:
Refer the image at following link, (-I wasn't able to use imgur as it is blocked in my network): http://www.flickr.com/photos/93397745@N05/8494742266/
- I have a CustomView that extends RelativeLayout (entire black part in image)
- This CustomView contains a component at top ViewTopBar (indicated in Red in image), which extends ViewGroup & is horizontally scrollable
- The ViewTopBar contains many child views. One of 'em is an IndicatorView (orange one in image), which is positioned in ViewTopBar after doing some calculations & calling layout(l,t,r,b) in ViewTopBar's onLayout() method.
- I want a vertical 1 pixel line to be displayed below the IndicatorView. It should start just below IndicatorView & cover the entire height of CustomView. (See the green colored line in image).
- This part doesn't matter, but just for information, the blue colored part in image is another Custom ViewGroup which is pretty complex to describe. (Also, there are still a few more components that are part of CustomView but not shown in the image as its not needed for my question.)
There, I hope I have the view explained. Now what I need is that the green 1px line should move horizontally so as to stay aligned below IndicatorView whenever horizontal scrolling is done. I've currently implemented it as follows:
- Placed the 1px line as child of CustomView.
- Whenever ViewTopBar's onLayout() is called, I update the GreenLine's LayoutParams & just modify the left margin depending on IndicatorView's position.
This works fine most of the time. But sometimes, when I do left-right-left-right scroll continuously, the 1pxLine does not stay in sync with the scrolling IndicatorView (--However, once scrolling stops, it comes back into sync!) So what changes do I need to make so that the line stays in sync even during scroll operations?
Please let me know if someone has been able to do this before.
Thanks,
-Kiran