高仿qq聊天界面,给有需要的人,界面效果如下:
真心觉得做界面非常痛苦,给有需要的朋友。
chat.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <RelativeLayout android:id="@+id/rl_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.01" android:background="@drawable/title_bar" android:orientation="vertical" > <Button android:id="@+id/chat_back" android:layout_width="70dp" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="10dp" android:background="@drawable/selector_btn_back" android:paddingLeft="10dp" android:text="返回" android:textColor="#ffffff" android:textSize="18sp" /> <TextView android:id="@+id/chat_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:textColor="#ffffff" android:textSize="20.0sp" /> </RelativeLayout> <ListView android:id="@+id/chat_listview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="10" android:cacheColorHint="#00000000" android:background="#FFFFFF" android:divider="@null" android:dividerHeight="5dp" android:scrollbars="none" > </ListView> <RelativeLayout android:id="@+id/rl_bottom" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.8" android:background="@drawable/layout_bg1" > <Button android:id="@+id/chat_send" android:layout_width="60dp" android:layout_height="40dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="10dp" android:background="@drawable/chat_send_button_bg" android:text="发送" android:textSize="20sp" /> <EditText android:id="@+id/chat_editmessage" android:layout_width="fill_parent" android:layout_height="40dp" android:layout_centerVertical="true" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_toLeftOf="@id/chat_send" android:background="@drawable/edittext1" android:singleLine="true" android:textSize="18sp" /> </RelativeLayout> </LinearLayout>
下面是布局文件中用到的各种资源
title_bar.9.png
selector_btn_back.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/top_back_leftpress" /> <item android:drawable="@drawable/top_back_left" /> </selector>
top_back_left.9.png
top_back_leftpress.9.png
layout_bg1.9.png
chat_send_button_bg.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="false" android:state_pressed="false" android:drawable="@drawable/chat_bottom_send_normal" /> <item android:state_pressed="true" android:drawable="@drawable/chat_bottom_send_pressed" /> <item android:state_focused="true" android:drawable="@drawable/chat_bottom_send_pressed" /> <item android:drawable="@drawable/chat_bottom_send_normal" /> </selector>
chat_bottom_send_pressed.9.png
chat_bottom_send_normal.9.png