实现后的效果如下图:
主要注意一点:当发送:http://www.baidu.com类的消息的时候,对方显示为超链接:
<?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="wrap_content"
android:orientation="vertical"
android:paddingTop="13dp" >
<TextView
android:id="@+id/timestamp"
style="@style/chat_text_date_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_chat_activity" >
<ImageView
android:id="@+id/iv_userhead"
android:layout_width="@dimen/size_avatar"
android:layout_height="@dimen/size_avatar"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="@dimen/margin_chat_activity"
android:background="@drawable/mini_avatar_shadow"
android:scaleType="fitXY" />
<TextView
android:maxWidth="225.0dip"
android:id="@+id/tv_chatcontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_chat_activity"
android:layout_toRightOf="@id/iv_userhead"
android:background="@drawable/chatfrom_bg"
android:autoLink="web"
android:clickable="true"
android:focusable="true"
android:gravity="left|center"
android:lineSpacingExtra="2dp"
android:minHeight="50dp"
android:textColor="#ff000000"
android:textSize="15sp" />
<TextView
android:id="@+id/tv_userid"
style="@style/chat_text_name_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@id/tv_chatcontent"
android:layout_below="@id/iv_userhead"/>
</RelativeLayout>
</LinearLayout>