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>
z-index
so that the object moves forwards or backwards in its page position as the user interacts with the page. – KittsListView
all items in the list are siblings, but changing the Z-index will have no effect since the list items do not overlap. Changing the Z-index of one item in the list will not make it jump forward to be in front of another view that isn't a sibling of the views in theListView
. – Nelrsa