I have table using table layout. I added the textview in it. I have shape drawable for each column. I defined the size in there.
<size android:width="100dp" android:height="50dp"/>
In column, there is a textview. My table will be generated by programmatically. When the text in text view is long, the column in table become large and there is no space for other column. I would like to enter new line if there is no space for text. the textview is depend on its text size. I want the fixed size of textview in a column. I have tried other posts but no luck.
Thanks.
Keep the width of the text view fixed and height as wrap content
<TextView android:id="@+id/sampleText"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:maxLines="4"
android:singleLine="false">
</TextView>
I found one solution for my requirement. I made fixed size column and scrollable textview. Firstly I remove size tag from shape drawable resource. And I add the following code for each column.
LayoutParams params = new TableRow.LayoutParams(100, 50);
I add the linear layout for each column and add scrollview into it. And then I add the textview in the scrollview. Actually I cannot know the length of text. Because the length of size may be vary, I choose this solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With