I need to add some space on top of the first row in my listView without using addheaderview and without touching the rows itself. Is there any way to do this?
5
-
thats not an option for my caseJoske369– Joske3692015-05-16 16:52:26 +00:00Commented May 16, 2015 at 16:52
-
API level 14 onwards: developer.android.com/reference/android/widget/Space.htmlManish– Manish2015-05-16 16:52:30 +00:00Commented May 16, 2015 at 16:52
-
it has to be in the list itselfJoske369– Joske3692015-05-16 16:52:50 +00:00Commented May 16, 2015 at 16:52
-
Maybe try fiddling with padding/margins.Manish– Manish2015-05-16 16:53:24 +00:00Commented May 16, 2015 at 16:53
-
The problem is that i'm using header view for a pulltorefresh listview already and i need to add space for the actionbar that has to slide up and down when the user scrolls the list up/down. the full list has to be shown when the actionbar is gone, and initially the list needs space on top to show the items like the listview is below the actionbarJoske369– Joske3692015-05-16 16:56:28 +00:00Commented May 16, 2015 at 16:56
Add a comment
|
1 Answer
In your adapter's getView method write something like:
if (position == 0) {
View v = new View(ctx);
v.getLayoutParams().height = 100;
return v;
}
Other way is just add margin to first view. Use same method as described above.
It kickoff example, not a working code.
2 Comments
Joske369
I think that this will result in the listview showing the wrong items and i'll have to do getItem for position +1 each time, which isn't really a good solution i think
Divers
If you don't want to use header, margins and item should be list itself - it only solution. And no, it will no show you wrong items.