android美化短信聊天记录使得输入长短信不顶格
发送短信界面:
[html]
<?xml version="1.0" encoding="utf-8"?>
<!-- 發送的短信:右邊 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="vertical" >
<!-- 包含占位框和收到短信框 -->
<LinearLayout
android:id="@id/sms_detail_send_right_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right" >
<!-- 占位框 -->
<TextView
android:id="@id/sms_detail_send_placeholder"
android:layout_width="30dp"
android:layout_height="wrap_content" />
<!-- 发出的短信 -->
<TextView
android:id="@id/sms_detail_send_right_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@drawable/sms_detail_content_right_bg"
android:gravity="center_vertical"
android:textColor="#000000" />
</LinearLayout>
<!-- 显示日期 -->
<TextView
android:id="@id/sms_detail_send_right_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
/>
</LinearLayout>
接收短信界面:
[html]
<?xml version="1.0" encoding="utf-8"?>
<!-- 收到的短信:左邊 -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:orientation="vertical" >
<!-- 短信接收日期 -->
<TextView
android:id="@id/sms_detail_receive_left_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/sms_detail_receive_left_layout" />
<!-- 占位框 -->
<TextView
android:id="@id/sms_detail_receive_placeholder"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignRight="@id/sms_detail_receive_left_message" />
<!-- 用LinearLayout包裹发出的短信框 -->
<LinearLayout
android:id="@id/sms_detail_receive_left_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/sms_detail_receive_placeholder" >
<!-- 发出的短信 -->
<TextView
android:id="@id/sms_detail_receive_left_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/sms_detail_content_left_bg"
android:gravity="center_vertical"
android:text="s"
android:textColor="#000000" />
</LinearLayout>
</RelativeLayout>
效果:
作者:yhm2046
补充:移动开发 , Android ,