TableLayout with images and text

I would like to show the image in the left cell and the text in the right cell of the scoreboard.

My problem is that the text view is floating outside the visible screen, so I cannot see all the text. The text should break into the visible right end of the screen. I tried setting maxWidthwith a pixel value, but this does not work.

Can anyone suggest 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> 
+3
source share
2 answers

Try setting the stretchColumns and shrinkColumns properties in 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 Jonathan Roth's answer in this post.

+1

android:shrinkColumns="1" TableLayout.

0

Source: https://habr.com/ru/post/1750628/


All Articles