I have a fragment with two RelativeLayout, one inside the other. This fragment is inside a tab. I want that the internal layout(layoutInternal) is scrollable, but with the following code does not work. I create the view object into the layoutInternal dinamically. Where is my mistake?
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutExsternal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="@dimen/fragmentHall_10dp_margin"
android:layout_marginTop="@dimen/fragmentHall_10dp_margin">
<RelativeLayout
android:id="@+id/layoutInternal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</RelativeLayout>
</ScrollView>
</RelativeLayout>
The following code is where i insert the view object (table) inside the intenalLayout.
while (iteratorTables.hasNext()) {
[...] //Here i calculate the dimension and coordinates
b_table = new ButtonTable(SelzApplication.getAppContext(),tableMap.getValue(), widthTable, heightTable);
b_table.setX(Math.round((tableMap.getValue().getX())* Xratio));
b_table.setY(Math.round((tableMap.getValue().getY())* Yratio));
//add Touch Listeners to the button
b_table.setOnLongClickListener(new OnLongTuchDragDrop());
b_table.setOnClickListener(new TableOnClick());
layoutInternal.addView(b_table, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
This is the screenshot of my app.
The
RelativeLayout layoutInternal
has the height initially set asandroid:layout_height="wrap_content"
but its content is initially empty because the content is created dynamically; for this reason is not scrollable.To solve this, when you finish to draw the tables into
RelativeLayout layoutInternal
, you have to set its height dynamically as below: