Android-如何使用图像、标题和副标题布局类似于iOS表格视图单元格的列表视图项?

Android-如何使用图像、标题和副标题布局类似于iOS表格视图单元格的列表视图项?,android,uitableview,listview,layout,Android,Uitableview,Listview,Layout,我正试图设计一个类似于普通iOS设计的Android列表视图单元——左边是一个图像,图像旁边有两个标签: 如何实现像基本iOS单元一样的Android单元布局,并带有图像、标题和字幕? 然而,我不确定什么是完成这项任务的正确布局。以下是我正在尝试的,它无法正确对齐元素: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/a

我正试图设计一个类似于普通iOS设计的Android列表视图单元——左边是一个图像,图像旁边有两个标签:

如何实现像基本iOS单元一样的Android单元布局,并带有图像、标题和字幕?

然而,我不确定什么是完成这项任务的正确布局。以下是我正在尝试的,它无法正确对齐元素:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1">

    <TextView
        android:id="@+id/api"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.47">

        <ImageView
            android:layout_width="@dimen/side_button_size"
            android:layout_height="@dimen/side_button_size"
            android:id="@+id/image"
            android:layout_gravity="left|top"
            android:background="@drawable/close_red" />

        <TextView
            android:id="@+id/title"
            android:layout_width="246dp"
            android:layout_height="82dp"
            android:layout_gravity="center_horizontal|top"
            android:text="This is title label" />

        <TextView
            android:id="@+id/subtitle"
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:layout_gravity="left|center_vertical"
            android:text="This is subtitle label" />
    </FrameLayout>

</LinearLayout>


使用一个包含
图像视图的水平
线性布局
和另一个(这次是垂直的)
线性布局
,其中包含2个
文本视图
s

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:layout_width="96dp"
        android:layout_height="96dp" />

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <Space
            android:layout_width="match_parent"
            android:layout_height="4dp" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>

</LinearLayout>

使用RelativeLayout时,可以指定每个子对象的相对位置。下面是一个例子:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:layout_width="@dimen/side_button_size"
        android:layout_height="@dimen/side_button_size"
        android:id="@+id/image"
        android:background="@drawable/close_red" />

    <TextView
        android:id="@+id/title"
        android:layout_width="246dp"
        android:layout_height="82dp"
        android:layout_toLeftOf="@id/image"
        android:layout_toStartOf="@id/image"
        android:text="This is title label" />

    <TextView
        android:id="@+id/subtitle"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_below="@id/title"
        android:text="This is subtitle label" />
</RelativeLayout>

使用Vogella提供的本教程:
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:layout_width="@dimen/side_button_size"
        android:layout_height="@dimen/side_button_size"
        android:id="@+id/image"
        android:background="@drawable/close_red" />

    <TextView
        android:id="@+id/title"
        android:layout_width="246dp"
        android:layout_height="82dp"
        android:layout_toLeftOf="@id/image"
        android:layout_toStartOf="@id/image"
        android:text="This is title label" />

    <TextView
        android:id="@+id/subtitle"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_below="@id/title"
        android:text="This is subtitle label" />
</RelativeLayout>