To ground this question, lets assume I have 10 TextViews with text numbered between 1 and 10. At any given time, I would like exactly three of the TextViews to be visible on the screen (no partial). For example, 1,2,3 might be visible or 5,6,7. I want to be able to scroll through this list of items (forwards and backwards) such that the first and last number take up 25% of the container they are in and the middle takes up 50%.
For example, when I start my activity I will see the following
1 <25% of container, TextView scaled to fill all 25%>
2 <50% of container, TextView scaled to fill all 50%>
3 <25% of container, TextView scaled to fill all 25%>
If the user scrolls down one item the following would be seen
2 <25% of container, TextView scaled to fill all 25%>
3 <50% of container, TextView scaled to fill all 50%>
4 <25% of container, TextView scaled to fill all 25%>
How could I (easily) do this? Something like a RecyclerView would be ideal but I don't see how I could get it to work. The best I can see is to use multiple view holder types and statically assign a type to each object in my list(like here and here). In other words if I start with this
1 <25% of container>
2 <50% of container>
3 <25% of container>
and scroll by one I will get this
2 <50% of container>
3 <25% of container>
4 <25% of container>
This isn't what I want though because TextView 2 maintains 50% of the container when it should be reduce to 25% when the user scrolled down. Another way would be to have only three TextViews and manually update the text of each whenever a scroll event occurs (via a listener), but that seems really hacky. This is such a simple thing I have seen appear in multiple apps so there must be a better solution than that.
What is the correct way of doing this and what ViewGroup/Layout/etc should I use?
Also, as an aside, if you give an example, please do so in Java not Kotlin.