3

I would like to show an image in the left cell and text in the right cell of a tablerow.

My problem is that the text-view is floating outside the visible screen, so I can't see the whole text. The text should break at the visible right end of screen. I've tried to set a maxWidth with a pixel value but that doesn't work.

Can anyone offer a solution to my problem. Maybe there is a better layout option?

my layout-definition:

<TableRow>
    <ImageView   
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:tint="#55ff0000"
      android:src="@drawable/bla"/> 
    <TextView  
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/aboutblaImageText" 
        android:textSize="6pt" 
        android:textColor="#FFF"
        android:maxWidth="100px"    
        />        
</TableRow> 
codingbadger
  • 42,678
  • 13
  • 95
  • 110
michbeck
  • 194
  • 1
  • 9
  • ok, the solution seems to be to use a nested linearlayout instead (outer linearlayout vertical, inner linearlayout horizontal). read about bad performance but it works – michbeck Jun 18 '10 at 08:05
  • thats the best solution, nest into a linearlayout. – Jorgesys Jun 18 '10 at 23:28
  • Can you elaborate on what you meant by nested linear layouts? Are you wrapping each element in the tablerow in its own layout? – vol Nov 14 '11 at 16:21

2 Answers2

1

Try setting the stretchColumns and shrinkColumns properties of the Table. It worked for me.

<TableLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:stretchColumns="0"
  android:shrinkColumns="1">

I took the idea from the Jonathan Roth answer in this post.

Community
  • 1
  • 1
Martillador81
  • 328
  • 4
  • 6
0

Add android:shrinkColumns="1" property to your TableLayout.

Emmanuel Sys
  • 817
  • 6
  • 12