Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,808,000 Members 48,813 Now Online
XDA Developers Android and Mobile Development Forum

Dynamic text wrap

Tip us?
 
vrenjithkr
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: May 2014
Default Dynamic text wrap

Hi,

In my application i am dynamically creating a table layout. In each row of the table layout have 3 text views. but the auto wrap of the text is not working on these text views in multiple screen resolutions.
 
MasterAwesome
Old
#2  
MasterAwesome's Avatar
Senior Member
Thanks Meter 775
Posts: 1,126
Join Date: Jun 2013
Quote:
Originally Posted by vrenjithkr View Post
Hi,

In my application i am dynamically creating a table layout. In each row of the table layout have 3 text views. but the auto wrap of the text is not working on these text views in multiple screen resolutions.
did you set the height and width to "wrap_content"? if yes and still didnt work try this

Code:
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
“Be yourself; everyone else is already taken.”― Oscar Wilde
 
vrenjithkr
Old
#3  
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: May 2014
Default android:layout_weight="1" android:ellipsize="none" android:maxLines="100" android:scr

Thank you for reply. I am dynamically crating the table layout. How can give these details in activity class..
 
MasterAwesome
Old
#4  
MasterAwesome's Avatar
Senior Member
Thanks Meter 775
Posts: 1,126
Join Date: Jun 2013
Quote:
Originally Posted by vrenjithkr View Post
Thank you for reply. I am dynamically crating the table layout. How can give these details in activity class..
You need to specify the layout parameters look at this sample program of adding a text view

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:stretchColumns="0,1" android:id="@+id/main_table" android:layout_weight="1" android:layout_height="wrap_content" android:layout_width="match_parent"> </TableLayout>

Once you ready with basic blank table layout open your respective activity page and define the table element

TableLayout t1; TableLayout tl = (TableLayout) findViewById(R.id.main_table);

Create table row header to hold the column headings

TableRow tr_head = new TableRow(this); tr_head.setId(10); tr_head.setBackgroundColor(Color.GRAY); tr_head.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

Add two data sections to the table row

TextView label_date = new TextView(this); label_date.setId(20); label_date.setText("DATE"); label_date.setTextColor(Color.WHITE); label_date.setPadding(5, 5, 5, 5); tr_head.addView(label_date);// add the column to the table row here TextView label_weight_kg = new TextView(this); label_weight_kg.setId(21);// define id that must be unique label_weight_kg.setText("Wt(Kg.)"); // set the text for the header label_weight_kg.setTextColor(Color.WHITE); // set the color label_weight_kg.setPadding(5, 5, 5, 5); // set the padding (if required) tr_head.addView(label_weight_kg); // add the column to the table row here

Regards
MasterAwesome
“Be yourself; everyone else is already taken.”― Oscar Wilde
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes