ListView padding on scrolling
Asked Answered
M

2

6

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)

Marti answered 1/4, 2014 at 7:0 Comment(1)
it looks like you have some pinned header?Bolide
V
14

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>
Vernievernier answered 1/4, 2014 at 7:4 Comment(1)
That is AWESOME, I was struggling was that and didn't knew about this parameter.Tomikotomkiel
M
0

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

listView.addHeaderView(header);

Memphian answered 1/4, 2014 at 7:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.