Android 带有图像和2文本视图的TableRow
我做这样的事情有困难: 我的xml代码在行中显示了3列,但我需要2列,第二列必须分为两个水平部分 My.xml:Android 带有图像和2文本视图的TableRow,android,android-tablelayout,tablerow,Android,Android Tablelayout,Tablerow,我做这样的事情有困难: 我的xml代码在行中显示了3列,但我需要2列,第二列必须分为两个水平部分 My.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_pa
<?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,然后在其中放置两个文本视图,或者对整行使用RelativeLayout
以下是第一个解决方案的示例:
<?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>
按图像放置LinearLayout,然后在其中放置两个文本视图,或者对整行使用RelativeLayout
以下是第一个解决方案的示例:
<?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>
谢谢你的快速回答@vtuhtan,但我仍然有问题。按照你的第二个答案,应用程序只显示第一行,他的内容仍然在左边显示一个imaget,在下一列显示一个文本。第三个文本没有出现。我不明白你的第一个回答方式。谢谢@vtuhtan,我稍后会尝试,但我有一个关于你的示例代码的问题要问你。在您看来,我必须将ListView和其他演示代码放在同一个xml中,或者最好将它们放在单独的文件中?是的,工作得很好!非常感谢你!我在同一个文件中维护了ListView。谢谢大家@MH谢谢你的快速回答@vtuhtan,但我仍然有问题。按照你的第二个答案,应用程序只显示第一行,他的内容仍然在左边显示一个imaget,在下一列显示一个文本。第三个文本没有出现。我不明白你的第一个回答方式。谢谢@vtuhtan,我稍后会尝试,但我有一个关于你的示例代码的问题要问你。在您看来,我必须将ListView和其他演示代码放在同一个xml中,或者最好将它们放在单独的文件中?是的,工作得很好!非常感谢你!我在同一个文件中维护了ListView。谢谢大家@MH看看-它会告诉你两种方法:一种是好的,另一种是。。。嗯,不太好谢谢@MH。我做了指南中的两种方式,但我的结果并不好:也许我必须将xml分成两个文件,一个是ListView,另一个是其余的代码。。。在链接中,您只能看到DB查询的三个结果中的一个。显示的行仅包含一个图像和两个文本之一。当我尝试使用指南的RelativeLayout示例时会发生这种情况,当我尝试使用第一个示例时,我的应用程序不会显示行:@MH。我看到第二种方式的指导工作!!!但在一个小空间中显示了3行。我拉了第一行,你可以看到在链接和。。。惊喜另外两排在那里。现在我的问题是如何扩大显示所有DB查询结果和显示第三个文本的空间。我还在工作…看看-它会告诉你两种方法:一种是好的,另一种是。。。嗯,不太好谢谢@MH。我做了指南中的两种方式,但我的结果并不好:也许我必须将xml分成两个文件,一个是ListView,另一个是其余的代码。。。在链接中,您只能看到DB查询的三个结果中的一个。显示的行仅包含一个图像和两个文本之一。当我尝试使用指南的RelativeLayout示例时会发生这种情况,当我尝试使用第一个示例时,我的应用程序不会显示行:@MH。我看到第二种方式的指导工作!!!但在一个小空间中显示了3行。我拉了第一行,你可以看到在链接和。。。惊喜另外两排在那里。现在我的问题是如何扩大显示所有DB查询结果和显示第三个文本的空间。我还在工作。。。