Android即时通讯聊天界面的通用定义XML布局

  
  
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ebebeb"
>
 
<RelativeLayout
android:id="@+id/top_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/height_top_bar"
android:layout_alignParentTop="true"
android:background="@color/common_top_bar_blue" >
 
<ImageView
android:id="@+id/iv_back"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:onClick="back"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:scaleType="centerInside"
android:src="@drawable/top_bar_back" />
 
<View
android:id="@+id/view_temp"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:layout_toRightOf="@id/iv_back"
android:background="#14191A" />
 
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/view_temp"
android:singleLine="true"
android:maxWidth="200dp"
android:ellipsize="end"
android:textColor="#ffffff"
android:textSize="18sp" />
 
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" >
 
<ImageView
android:id="@+id/iv_setting"
android:layout_width="@dimen/height_top_bar"
android:layout_height="@dimen/height_top_bar"
android:padding="9dp"
android:scaleType="centerInside"
android:src="@drawable/icon_single_setting" />
 
<ImageView
android:visibility="gone"
android:id="@+id/iv_setting_group"
android:layout_width="@dimen/height_top_bar"
android:layout_height="@dimen/height_top_bar"
android:padding="9dp"
android:scaleType="centerInside"
android:src="@drawable/icon_group_setting" />
</LinearLayout>
</RelativeLayout>
 
<LinearLayout
android:id="@+id/bar_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
>
 
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#C0C0C0" />
 
<LinearLayout
android:id="@+id/rl_bottom"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#ffffff"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingTop="4dp" >
 
<Button
android:id="@+id/btn_set_mode_voice"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginLeft="6dp"
android:background="@drawable/icon_chat_voice"
android:onClick="setModeVoice"
android:visibility="visible" />
 
<Button
android:id="@+id/btn_set_mode_keyboard"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginLeft="6dp"
android:background="@drawable/chatting_setmode_keyboard_btn"
android:onClick="setModeKeyboard"
android:visibility="gone" />
 
<LinearLayout
android:id="@+id/btn_press_to_speak"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="6dp"
android:layout_weight="1"
android:background="@drawable/chat_press_speak_btn"
android:gravity="center"
android:visibility="gone" >
 
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="@string/button_pushtotalk"
android:textColor="#666666"
android:textSize="16sp" />
</LinearLayout>
 
<RelativeLayout
android:id="@+id/edittext_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_weight="1"
android:gravity="bottom" >
 
<com.fanxin.app.widget.PasteEditText
android:id="@+id/et_sendmessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="35dip"
android:background="@null"
android:maxLines="3"
android:minHeight="40dp"
android:onClick="editClick"
android:paddingBottom="3dp"
android:paddingLeft="1dp"
android:paddingRight="1dp"
android:paddingTop="3dp"
android:textSize="16sp" />
 
<ImageView
android:id="@+id/iv_emoticons_normal"
android:layout_width="24dip"
android:layout_height="24dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical|right"
android:layout_margin="1dip"
android:scaleType="fitCenter"
android:src="@drawable/icon_chat_emoji_normal"
android:visibility="visible" />
 
<ImageView
android:id="@+id/iv_emoticons_checked"
android:layout_width="24dip"
android:layout_height="24dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical|right"
android:layout_margin="1dip"
android:scaleType="fitCenter"
android:src="@drawable/icon_chat_emoji_checked"
android:visibility="invisible" />
</RelativeLayout>
 
<Button
android:id="@+id/btn_more"
android:layout_width="32dip"
android:layout_height="32dip"
android:layout_marginLeft="4dp"
android:layout_marginRight="10dp"
android:background="@drawable/icon_chattype_add"
android:onClick="more" />
 
<Button
android:id="@+id/btn_send"
android:layout_width="42dp"
android:layout_height="32dp"
android:layout_marginRight="4dp"
android:background="@drawable/chat_send_btn_selector"
android:onClick="onClick"
android:text="@string/button_send"
android:textColor="#666666"
android:textSize="16sp"
android:visibility="gone" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#C0C0C0" />
<LinearLayout
android:id="@+id/more"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical"
android:visibility="gone" >
 
<!-- 表情图片 -->
 
<LinearLayout
android:id="@+id/ll_face_container"
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="vertical"
android:visibility="visible" >
 
<android.support.v4.view.ViewPager
android:id="@+id/vPager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
 
<!-- 图片,表情,名片等按钮 -->
 
<LinearLayout
android:id="@+id/ll_btn_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone" >
 
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginTop="6dp"
android:weightSum="4" >
 
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
 
<RelativeLayout
android:layout_width="64dp"
android:layout_height="64dp" >
 
<ImageView
android:id="@+id/btn_take_picture"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_centerInParent="true"
android:background="@drawable/icon_chat_photo"
android:clickable="true"
android:onClick="onClick"
android:scaleType="fitCenter" />
</RelativeLayout>
 
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/attach_take_pic"
android:textColor="#727171" />
</LinearLayout>
 
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
 
<RelativeLayout
android:layout_width="64dp"
android:layout_height="64dp" >
 
<ImageView
android:id="@+id/btn_picture"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_centerInParent="true"
android:background="@drawable/icon_chat_pic"
android:clickable="true"
android:onClick="onClick"
android:scaleType="fitCenter" />
</RelativeLayout>
 
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/attach_picture"
android:textColor="#727171" />
</LinearLayout>
 
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
 
<RelativeLayout
android:layout_width="64dp"
android:layout_height="64dp" >
 
<ImageView
android:id="@+id/btn_location"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_centerInParent="true"
android:clickable="true"
android:onClick="onClick"
android:scaleType="fitCenter"
android:src="@drawable/icon_chat_location" />
</RelativeLayout>
 
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/attach_location"
android:textColor="#727171" />
</LinearLayout>
 
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
 
<RelativeLayout
android:layout_width="64dp"
android:layout_height="64dp" >
 
<ImageView
android:id="@+id/btn_video"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_centerInParent="true"
android:clickable="true"
android:onClick="onClick"
android:scaleType="fitCenter"
android:src="@drawable/icon_chat_vedio" />
</RelativeLayout>
 
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="视频"
android:textColor="#727171" />
</LinearLayout>
</LinearLayout>
 
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginTop="6dp"
android:visibility="gone"
android:weightSum="4" >
 
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
 
<RelativeLayout
android:layout_width="64dp"
android:layout_height="64dp" >
 
<ImageView
android:id="@+id/btn_file"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_centerInParent="true"
android:background="@drawable/chat_file_selector"
android:clickable="true"
android:onClick="onClick"
android:scaleType="fitCenter" />
</RelativeLayout>
 
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/attach_file"
android:textColor="#727171" />
</LinearLayout>
 
<LinearLayout
android:id="@+id/container_voice_call"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
 
<RelativeLayout
android:layout_width="64dp"
android:layout_height="64dp" >
 
<ImageView
android:id="@+id/btn_voice_call"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_centerInParent="true"
android:background="@drawable/chat_voice_call_selector"
android:clickable="true"
android:onClick="onClick"
android:scaleType="fitCenter" />
</RelativeLayout>
 
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/attach_voice_call"
android:textColor="#727171" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
 
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bar_bottom"
android:layout_below="@id/top_bar" >
 
<ProgressBar
android:id="@+id/pb_load_more"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_centerHorizontal="true"
android:visibility="gone" />
 
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/pb_load_more"
android:cacheColorHint="#00000000"
android:divider="@null"
android:dividerHeight="5dp"
android:listSelector="#00000000"
android:scrollbarStyle="outsideOverlay"
android:transcriptMode="normal" />
 
<RelativeLayout
android:id="@+id/recording_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/recording_hint_bg"
android:padding="10dp"
android:visibility="invisible" >
 
<ImageView
android:id="@+id/mic_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/record_animate_01" />
 
<TextView
android:id="@+id/recording_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/mic_image"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:padding="2dp"
android:text="@string/move_up_to_cancel"
android:textSize="10sp" />
</RelativeLayout>
</RelativeLayout>
 
</RelativeLayout>

里面的布局可以直接使用,界面逻辑没有添加,自己根据实际的需求,自己定义!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值