Diego Garcia Diego Garcia - 2 months ago 13
Android Question

If a ScrollView is the parent, it doesn't show a TableLayout into a RelativeLayout(Android)

I have this xml file:

<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout android:id="@+id/conteiner_2"
android:layout_width="500px"
android:layout_height="500px"
android:background="@drawable/gradient_2">
</RelativeLayout>
</HorizontalScrollView>
</ScrollView>


And I am trying to create a
TableLayout
which if I delete the
ScrollViews
it appears, but when I let it like before the
TableLayout
isn't show.
This is my code:

TableLayout table = new TableLayout(this);
RelativeLayout.LayoutParams paramsTable = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
TableLayout.LayoutParams paramsRow = new TableLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,0,1.0f);
TableRow.LayoutParams paramsCol = new TableRow.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT,1.0f);
for(int row = 0 ; row < rows ; row++){
TableRow row = new TableRow(this);
row.setLayoutParams(paramsRow);

for(int col = 0 ; col < column ; col++){
TextView text = new TextView(this);
text.setLayoutParams(paramsCol);
text.setText(row + "-" + col);
row.addView(text);
}
table.addView(row);
}

tabla.setLayoutParams(paramsTable);
conteiner.addView(table);


Sorry for my poor English, I hope I made myself understood.

<<< EDIT >>>
I have to put another layout inside the
RelativeLayout
, and it works.

Answer

I have to put another layout inside the RelativeLayout, and it works.

Comments