Android与ListView的相对布局
我正在使用一个列表视图,其中的每个项目都有一个RelativeLayout。我可以正确显示头像、标题和文本信息,但我无法获得与标题位于同一行的时间戳。因此,化身在左边,标题在顶部,时间戳在最右边,沿着同一行,文本信息在正下方 布局如下:Android与ListView的相对布局,android,android-layout,android-relativelayout,Android,Android Layout,Android Relativelayout,我正在使用一个列表视图,其中的每个项目都有一个RelativeLayout。我可以正确显示头像、标题和文本信息,但我无法获得与标题位于同一行的时间戳。因此,化身在左边,标题在顶部,时间戳在最右边,沿着同一行,文本信息在正下方 布局如下: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<?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="?android:attr/listPreferredItemHeight"
>
<ImageView
android:id="@+id/avatar"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:scaleType="center"
android:layout_marginRight="3dip"
android:src="@drawable/icon"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/text_title"
android:layout_toRightOf="@id/avatar"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:gravity="center_vertical"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#FFFFFF"
/>
<TextView
android:id="@+id/time_stamp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="@id/text_title"
/>
<TextView
android:id="@+id/text_info"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_toRightOf="@id/avatar"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:singleLine="true"
/>
</RelativeLayout>
对于
时间戳
文本视图,使用布局_alignParentRight=“true”
和布局_alignTop
设置为标题文本视图。因此,它将位于列表的右侧,顶部将与标题对齐