I'm using the TwoWayView
library : https://github.com/lucasr/twoway-view to try and implement a horizontal ListView
of sorts to overhaul what I had before. (HorizontalScrollView
with a horizontally oriented LinearLayout
that I add views to)
I want to have a margin
before the first item, so there's a blank space at the left when the View
is first created. But when scrolled, the blank space would be scrolled and disappear as well. When using a normal ListView
it is essentially a HeaderView
that I want.
When I implemented the scroll using HorizontalScrollView
, I simply programmatically checked the first item and added the margin, which worked since its parent was LinearLayout
and accepts margins. But I cannot do this in the getView()
of the adapter used for this AdapterView
since its LayoutParams
do not inherit ViewGroup.MarginLayoutParams
I've also tried setting clipToPadding="false"
, but the views gets recycled too early, which is unacceptable since the padding I need is noticeably big.
Is there a way to achieve this behavior without moving all the HeaderView
code from ListView
into the TwoWayView
library?
You can try something like this:
on getView(int pos, View convertView, ViewGroup parent){}
Hope this would help you.