Search code examples
androidhorizontalscrollviewandroid-overscoll

Adding a new item in a horizontal ListView when over scrolled to the right: Android


I have a Horizontal ScrollView that shows a number of items. I want to show an extra item only when the user over-scrolls to the right.

Then when the user scrolls back to the left this extra item should disappear. The View should normally scroll only in the first item and only on explicitly doing an over-scroll the extra item should be visible.

I am not able to figure out how to do this. Could someone please provide pointers on how to achieve this behaviour.

Thanks Sunny.


Solution

  • The easiest way I would do it is define that extra item in the scrollview, but set it's visibility. You can do it in code. Here's a snippet.

    yourobject.setVisibility(View.GONE);
    yourobject.setVisibility(View.VISIBLE);