I have a ScrollView
that I would like to have a variable number of children in. Easy game, use LinearLayout
.
Now, I am looking for a way to make the widths of the children some proportion of the ScrollView
itself (it is going to be placed in another auto-laid out view).
I have tried using LinearLayout
weights (and weightSum) to keep them proportional to themselves, but then they just fill the ScrollView
and don't allow scrolling.
I have android:fillViewport="true"
set on the ScrollView
so that it fills its container, but I can't seem to find a way to make the children some fraction of the ScrollView itself.
Basically I want ALL the children to have a fixed width of say a 3rd of the available space, so that while scrolling at most 3 items are shown, and they are proportional to the available space.
My thoughts are that I will need to create a CustomScrollView
that extends ScrollView
, and then @Override
the onMeasure()
method, is this the way, or is there an easier, more elegant solution (hopefully using the layout_weights engine already in LinearLayout)?
Any help would be much appreciated!
P.S. I had a beautiful picture drawn, but apparently you need 10 rep, lame to the n^th degree. I would love to have contributed to more questions on SO, but I need like 15 rep to vote up a question that helped me? That means I need to ask 15 questions, of which I can already find all the answers on here.