android 聊天界面开源,android示例一之聊天页面UI

本文介绍了一个Android聊天界面的实现,包括使用ListView显示聊天信息,EditText作为输入框,Button发送消息。消息UI通过自定义的MsgAdapter在ListView中显示,根据Msg的类型决定使用左侧或右侧的气泡布局。
摘要由CSDN通过智能技术生成

聊天页面UI

一个普通聊天页面的ui,如下图:

示意图

416304f52ac241af75d64116eb6bbf10.png

##UI结构

ListView作为聊天信息显示区域

EditText作为信息输入框

Button信息发送按钮

其中ListView的context layout 设计为包含左右两个TextView的设计,通过Adapter在显示消息时决定使用layout的哪个TextView显示消息。

左右两个TextView背景图(仿聊天气泡)

18725601c1d82b53c4451871b2dd6c22.png

##界面布局(layout)

**activity_main.xml **

主界面

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#d8e0e8"

android:orientation="vertical"

android:paddingBottom="16dp"

android:paddingLeft="16dp"

android:paddingRight="16dp"

android:paddingTop="16dp"

tools:context="study.zhukai.com.chatroom.MainActivity">

android:id="@+id/msg_list_view"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1"

android:divider="#0000">

android:layout_width="match_parent"

android:layout_height="wrap_content">

android:id="@

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值