【问题标题】:TableLayout with images and text带有图像和文本的表格布局
【发布时间】:2011-03-05 07:39:34
【问题描述】:

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

我的问题是文本视图浮动在可见屏幕之外,所以我看不到整个文本。文本应在屏幕可见的右端中断。我尝试使用像素值设置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> 

【问题讨论】:

  • 好的,解决方案似乎是使用嵌套的线性布局(外部线性布局垂直,内部线性布局水平)。阅读有关性能不佳但有效的信息
  • 这是最好的解决方案,嵌套到线性布局中。
  • 您能否详细说明嵌套线性布局的含义?您是否将 tablerow 中的每个元素都包装在自己的布局中?

标签: android tablelayout


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-02
      • 2012-12-06
      • 1970-01-01
      • 2019-12-28
      • 1970-01-01
      • 2013-11-27
      相关资源
      最近更新 更多