Search code examples
androidxmllistviewstylingfading

In a ListView, is it possible to only fade in elements from one edge?


I'm utilizing a simple listview and want to fade one edge, not two or four as I'm currently experiencing using:

<ListView
    android:id="@+id/main_feed"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:requiresFadingEdge="vertical"
    android:fadingEdgeLength="50dp" >
</ListView>

I want to only fade one edge (the bottom edge), but doing either 'vertical' or 'horizontal' in requiresFadingEdge fades top/bottom or left/right, respectively.

Any Suggestions?


Solution

  • I know this is an old question, but I found a way to do this. Just make your own class that extends ListView and override the method getTopFadingStrength() like this:

    @Override
    protected float getTopFadingEdgeStrength() {
        return 0;
    }
    

    This will remove the fading on the top, but keep the fading on the bottom, then in your XML just use your ListView implementation.