How to create a whole layout (Relative/Linear) multiple times in Android? I want the same layout to be created multiple times inside a horizontal scroll view.
You can use RecyclerView
for Horizontal scrolling-
or-
Take horizontal scrollview reference in java code by findViewById
.
Create one other xml for view which you want to display multiple
time.
inflate that view by getlayoutinflator
. Create a loop in
view.
create a linearlayout at runtime and add those view to it by add view
take a idea and modify the below code
scrollview = findViewByID(scrollview);
LinearLayout ll = new LinearLayout(this);
for(your loop){
View v= getLayoutInflator().inflate(R.layout.xml);
ll.addView(v);
}
scrollview.addView(ll);