TableLayout包含图像和文本

时间:2010-06-18 07:43:52

标签: android tablelayout

我想在左侧单元格中显示图像,在右侧单元格中显示文本。

我的问题是文本视图浮动在可见屏幕之外,所以我看不到整个文本。文本应在屏幕的可见右端中断。我试图设置一个带有像素值的maxWidth,但这不起作用。

任何人都可以为我的问题提供解决方案。也许有更好的布局选项?

我的布局定义:

<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> 

2 个答案:

答案 0 :(得分:1)

尝试设置Table的stretchColumns和shrinkColumns属性。它对我有用。

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

我从this帖子中的Jonathan Roth回答中提出了这个想法。

答案 1 :(得分:0)

android:shrinkColumns="1"属性添加到TableLayout