I managed to achieve this using a scroll view with one relative arrangement as a child. Then I dynamically place the views, defining the rule and margin:
for (int i = 0; i < 30; i++) { TextView tv = new TextView(context); tv.setText("Text \n Text" + i); tv.setBackgroundColor(i % 2 == 0 ? Color.RED : Color.GREEN); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); lp.leftMargin = 0; lp.topMargin = (i * 45); rl.addView(tv, lp); }
Later, you can control the positioning of the subrecords by changing their y value (for example: if you want to add animation).
This is the end result:

source share