android 实战 制作聊天界面

RecyclerView学了这么久,也应该来试一下实战了,这次来试一下做一个聊天界面,做聊天界面需要两张图片来分别做收到信息和发送信息的背景图,是需要制作Nine-Patch图片,做Nine-Patch图片也很简单,直接右键生成然后编辑就行,不过要注意的是,图片的后缀要是png才可以

我们先来看一下效果图
在这里插入图片描述
看起来挺不错的,接下来来实现一下
因为我们会用到RecyclerView,所以首先添加一下依赖,打开app/build.gradle添加依赖

   dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        implementation 'com.android.support:recyclerview-v7:28.0.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    }

接着来编写一下主页面,修改activity_main.xml

<?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="match_parent"
    android:orientation="vertical"
    android:background="@drawable/bac"


   >

    <android.support.v7.widget.RecyclerView
        android:id="@+id/msg_recycle_view"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">



    <EditText
        android:id="@+id/input_txet"
        android:layout_
  • 4
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值