带有图像和文本的表格布局

发布于 2024-09-06 06:59:58 字数 708 浏览 1 评论 0原文

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

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

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> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无名指的心愿 2024-09-13 06:59:58

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

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

梦在深巷 2024-09-13 06:59:58

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

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

我从这篇文章中的 Jonathan Roth 答案中得到了这个想法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文