Android Relative Layouts with ListView
-
29-10-2019 - |
Question
I'm using a ListView with a RelativeLayout for each of the Items in it. I can display the avatar, title and text info correctly but I can not get the time_stamp to sit on the same line as the title. So the avatar is on the left, title on top with the timestamp to the far right along the same line and the text_info directly underneath.
Layout is as follows:
<?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>
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow