I am creating an app that has a tablelayout inside a scrollview but having problems getting it to load correctly. The tablerows and contents of the row is being dynamically created.
main.xml file
In code I am creating tablerows with imageview inside the table row.
code
Results. The tablelayout is created with images but it's creating the tablerows horizontally instead of vertically. Any suggestions on gettting table to create correctly?
main.xml file
Code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.yaadspice.epgtv.Activity.MainActivity">
<ScrollView
android:id="@+id/vsC"
android:layout_width="100dp"
android:layout_height="320dp"
android:layout_marginBottom="-350dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent">
<TableLayout
android:id="@+id/tableC"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TableLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
In code I am creating tablerows with imageview inside the table row.
code
Code:
private void createTables() {
this.tableC.addView(componentCTableRow());
}
TableRow componentCTableRow() {
TableRow componentCTableRow= new TableRow(this);
TableRow.LayoutParams params= new TableRow.LayoutParams( TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
for (int i=0; i<g.myList.size(); i++){
ImageView imageViewC= new ImageView(this);
Picasso.with(this)
.load(g.myList.get(i).getIcon())
.placeholder(R.drawable.lb_ic_sad_cloud)
.into(imageViewC);
imageViewC.setLayoutParams(params);
componentCTableRow.addView(imageViewC);
}
return componentCTableRow;
}
Results. The tablelayout is created with images but it's creating the tablerows horizontally instead of vertically. Any suggestions on gettting table to create correctly?