I need to set parameters for a textview that is created dynamically, the text of the textview is from database. As some text may be large it exceeds the mobile window and continues to show the text in single line
TableLayout tbl=(TableLayout) findViewById(R.id.tbla);
TableRow row= new TableRow(this);
TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT);
row.setLayoutParams(lp);
TextView tv1 = new TextView(this);
tv1.setSingleLine(false);
tv1.setEllipsize(null);
tv1.setTextSize(getResources().getDimension(R.dimen.textsize));
tv1.setHorizontallyScrolling(false);
tv1.setText(log);
row.addView(tv1);
tbl.addView(row,i);
I have read some articles and made some possible properties to it.. plz help me to make it auto resize..
Just add this line on your code, before adding your TextView
to the TableRow
:
tv1.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f));
It will make your TextView
to always show all its height.