1

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

4

1 回答 1

0

我将取出IndicatorView1px ViewTopBar-line-view 和 1px-line-view 一起包含在一些容器布局中,然后将其放入其中CustomView。这样,您可以整体控制该元素的位置,而不是让一个“追赶”另一个。不确定它是否适用于您的情况。

于 2013-02-21T08:34:02.060 回答