I m having a Custom List for a chat application.
It has basically Two imageView in the either side and textView for the "chat message" in the middle. Below all the three above there is textview for time at the bottom. The screenshot below would better suffice.
The problem here is the time textView is overlapping over the imageView if the text of the "chat message" is only line.
This problem is better corrected with html-css as float clear:both.
I went through another answer for this with a nested RelativeLayout within LinearLayout here but i want to keep it clean with a single RelativeLayout.
The layout xml is as below -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/icon1"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/msgText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:textSize="20sp"
android:layout_marginLeft="42dp"
android:layout_marginRight="42dp"
android:text="this is a test" />
<ImageView
android:id="@+id/icon2"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/timeText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="40px"
android:layout_marginTop="10dp"
android:layout_below="@+id/msgText"
android:layout_alignParentRight="true"
android:gravity="right"
/>
</RelativeLayout>
The screenshot for this as below -