带有图像和 2 个 TextView 的 TableRow [英] TableRow with image and 2 TextView
本文介绍了带有图像和 2 个 TextView 的 TableRow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在做这样的事情时遇到了问题:http://imageshack.us/photo/my-images/824/examplehm.png/
I`m having problems for do something like this: http://imageshack.us/photo/my-images/824/examplehm.png/
我的 xml 代码在行中显示 3 列,但我想要 2 列,第二列必须分为两个水平部分.
My xml code shows 3 columns in the row but i want 2 columns and the second column must be divided in two horizontal parts.
我的 .xml:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
<TableRow>
<ImageView android:id="@+id/imagen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="2dip"
android:paddingRight="5dip" />
<TextView android:id="@+id/cabecera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="12px" />
<TextView android:id="@+id/descripcion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="normal"
android:textSize="10px" />
</TableRow>
</TableLayout>
有人可以帮助我吗?
谢谢.
推荐答案
将 LinearLayout
放在图片旁边,然后放入两个 TextViews
,或者使用 RelativeLayout
用于整行.
Put LinearLayout
by the image and then put in it two TextViews
, or use RelativeLayout
for entire row.
这是第一个解决方案的示例:
Here is example of the first solution:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow>
<ImageView android:id="@+id/imagen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="2dip"
android:paddingRight="5dip" android:src="@drawable/ic_launcher"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" android:gravity="center_vertical">
<TextView android:id="@+id/cabecera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="12px"
android:text="TextView"/>
<TextView android:id="@+id/descripcion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="normal"
android:textSize="10px"
android:text="TextView" />
</LinearLayout>
</TableRow>
这篇关于带有图像和 2 个 TextView 的 TableRow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文