【问题标题】:How to make a row of ListView like this?如何制作这样的一行ListView?
【发布时间】:2010-03-30 09:24:13
【问题描述】:

抱歉,这是我第一次在这里提问。所以,我没有权限上传图片来描述。没关系。我想做的是这样的一排ListView。左边的块是一个图标。

如果您能反馈正确的 XML 标签,我们将不胜感激。谢谢。

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
--------
| |一些文字     一些文字
| |一些文字     一些文字
--------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

【问题讨论】:

  • 检查这个CommonsWare's answer 不要重复这个问题。如果您没有得到答案,请先搜索问题,然后再提问。
  • 左边的图片/图标应该是“rowspan”,右边的文字有点像一个有四个单元格的表格。

标签: android listview layout


【解决方案1】:
<LinearLayout android:layout_height="wrap_content"
    android:layout_width="fill_parent">
    <ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:src="@drawable/image" />
    <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="Some text some text some text some text"
        android:layout_weight="1" />
    <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="Some text some text some text some text"
        android:layout_weight="1" />
</LinearLayout>

【讨论】:

  • 不,这不是。但是谢谢,我会在我的问题中明确说明。
【解决方案2】:

在过去的几个小时里,我终于自己找到了解决方案。希望这可以对其他人有所帮助。这是我对这个论坛的第一个贡献。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="60px">
    <ImageView
        android:layout_centerVertical="true"
        android:id="@+id/image"
        android:layout_height="32px"
        android:layout_width="32px"
        android:layout_marginLeft="20px" />
    <TableLayout
        android:layout_height="fill_parent"
        android:layout_marginRight="0px"
        android:layout_width="fill_parent"
        android:layout_marginLeft="62px">
        <TableRow
            android:minHeight="30px">
            <TableRow
                android:layout_width="fill_parent"
                android:minHeight="40px">
                <TextView
                    android:text="SOME TEXT"
                    android:layout_width="wrap_content"
                    android:ellipsize="end"
                    android:id="@+id/title"
                    android:textSize="10pt"
                    android:width="150px"
                    android:layout_gravity="fill_vertical"
                    android:gravity="bottom"
                    android:minHeight="40px"
                    android:textStyle="bold" />
                <TextView
                    android:text="99999"
                    android:id="@+id/amount"
                    android:textSize="10pt"
                    android:paddingRight="20px"
                    android:minHeight="40px"
                    android:gravity="bottom|right"
                    android:textStyle="bold"
                    android:width="108px" />
            </TableRow>
        </TableRow>
        <TableRow
            android:minHeight="20px">
            <TableRow
                android:layout_width="fill_parent">
                <TextView
                    android:text="SOME TEXT"
                    android:layout_width="wrap_content"
                    android:ellipsize="end"
                    android:id="@+id/description"
                    android:width="150px"
                    android:gravity="top"
                    android:layout_gravity="fill_vertical"
                    android:minHeight="20px" />
                <TextView
                    android:text="some text"
                    android:id="@+id/date"
                    android:paddingRight="20px"
                    android:minHeight="20px"
                    android:gravity="top|right"
                    android:width="108px" />
            </TableRow>
        </TableRow>
    </TableLayout>
</RelativeLayout>

【讨论】:

  • 这个使用RelativeLayout和TableLayout的组合有点棘手。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-01-27
  • 1970-01-01
  • 2021-12-22
  • 2016-03-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多