Question

I want to add padding at top of ListView and after scrolling ListView i want to set padding to 0.

I've tried adding padding at top of ListView and Layout but both don't work.

Here's what I exactly want:

Before scrolling

(At top of ListView / Before scrolling)

After scrolling

(Scrolled down ListView / After scrolling)

Was it helpful?

Solution

you have to set android:clipToPadding="false"

like this:

<ListView
    android:id="@+id/your_listview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:cacheColorHint="#00000000"
    android:paddingBottom="15dp"
    android:paddingTop="15dp"
    android:clipToPadding="false"
    android:scrollbars="none" >
</ListView>

OTHER TIPS

Try adding header to list view where header can be a view that takes care of the padding.

listView.addHeaderView(header);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top