Here is how I would go about achieving the effect you desire:
Each item in the list should have a red bar in it that is the height of the item. That way all the red bars line up making it look like there is just one red bar when in fact there is one per item.
If you are using a FrameLayout
, the order of the children determines the drawing order, for example the 3rd child of a FrameLayout
will appear on top of the 1st and 2nd child.
Then at runtime you can arrange the red bar above or below the contents of a each item. In the bindView
method of your adapter you can use the bringToFront
method to bring the red bar to the front for that view. Don't forget that views are recycled in the ListView
so you will need to move the red bar to correct z position every time.
Here are is a very stripped down example XML file for an item in the view, let me know if you need more information.
item_red_bar_bottom.xml:
<FrameLayout ...>
<ImageView .../> <!-- Red bar on bottom -->
<FrameLayout ...>
<!-- Normal item contents go here -->
</FrameLayout>
</FrameLayout>