Hi, i have a simple activity with a linearlayout and a scrollview. Dynamically i add a tablerow with one textview and a button. But when i launch app scrollview doesn't contain all tablerow... infact the first is "this is a text - 3 -" Rows from 1 to 3 are cut off from screen!
this is java code : int contatore = 0; final TableLayout tl = (TableLayout)findViewById(R.id.dettaglio); tl.setPadding(5, 0, 0, 0);
if (text_to_do.moveToFirst())
{
do {
contatore=contatore+1;
int index = text_to_do.getColumnIndex("testo");
String testo = text_to_do.getString(index);
final TableRow tr = new TableRow(this);
final TextView casella_testo = new TextView(this);
if (contatore%2==0) {
tr.setBackgroundColor(getResources().getColor(R.color.pari));
}
else
{
tr.setBackgroundColor(getResources().getColor(R.color.dispari));
}
testo = "This is a text - "+contatore + " -";
casella_testo.setText(testo);
casella_testo.setWidth(200);
casella_testo.setPadding(10, 0, 0, 10);
Button butt = new Button(this);
butt.setBackgroundResource(R.drawable.try_this);
Typeface font = Typeface.createFromAsset(getAssets(), "BAARS___.TTF");
casella_testo.setTextSize(20);
casella_testo.setTypeface(font);
tr.addView(casella_testo);
tr.addView(butt);
tr.setGravity(Gravity.CENTER);
butt.setHeight(LayoutParams.WRAP_CONTENT);
butt.setWidth(LayoutParams.WRAP_CONTENT);
butt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// do something....
startActivity(intent);
}
});
tr.setPadding(0,10,0,0);
tl.addView(tr,new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
} while (text_to_do.moveToNext());
}
And XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingLeft="0dip"
android:paddingRight="1dip"
android:orientation="vertical">
<ScrollView
android:id="@+id/scrllvwNo1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal">
<TableLayout
android:id="@+id/dettaglio"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:stretchColumns="0">
</TableLayout>
</ScrollView>
</LinearLayout>
with 16 rows there is a problem... row from 1 to 3 are not show ! http://i30.tinypic.com/2vs0roh.jpg