Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

Dynamic text wrap

OP vrenjithkr

29th May 2014, 11:51 AM   |  #1  
OP Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: May 2014
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.
1st June 2014, 07:58 PM   |  #2  
MasterAwesome's Avatar
Senior Member
Thanks Meter: 810
 
1,143 posts
Join Date:Joined: Jun 2013
More
Quote:
Originally Posted by vrenjithkr

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"
2nd June 2014, 05:41 AM   |  #3  
OP Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: May 2014
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..
2nd June 2014, 06:08 AM   |  #4  
MasterAwesome's Avatar
Senior Member
Thanks Meter: 810
 
1,143 posts
Join Date:Joined: Jun 2013
More
Quote:
Originally Posted by vrenjithkr

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
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes