Android仿微信语音聊天demo

       其实我接触android时间也不是很久,但是发现android远远比我们想象的要有趣并且复杂很多,所以还是要多花点时间来写一写这些demo例子,这个程序是我从慕课网上学来的,因为毕竟要自己手写,才能体会到程序的完整性,所以我还是建议大家自己手写代码,大部分代码我已经添加了注释,如果有疑问,大家一起来讨论讨论。


效果图




主布局文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.weixin_record.MainActivity" >

    <ListView
        android:id="@+id/listview"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#ebebeb"
        android:divider="@null"
        android:dividerHeight="10dp" >
    </ListView>

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

        <!-- minHeight消除主界面上的一些间距 -->

        <com.nickming.view.AudioRecordButton
            android:id="@+id/recordButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="7dp"
            android:layout_marginLeft="50dp"
            android:layout_marginRight="50dp"
            android:layout_marginTop="6dp"
            android:background="@drawable/button_recordnormal"
            android:gravity="center"
            android:minHeight="0dp"
            android:padding="5dp"
            android:text="@string/normal"
            android:textColor="#727272" >
        </com.nickming.view.AudioRecordButton>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#ccc" />
    </FrameLayout>

</LinearLayout>

listview的item布局文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_marginTop="5dp" >

    <ImageView
        android:id="@+id/item_icon"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="5dp"
        android:src="@drawable/icon" />

    <FrameLayout
        android:id="@+id/recorder_length"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@id/item_icon"
        android:background="@drawable/chatto_bg_focused" >
        
      <View 
          android:id="@+id/id_recorder_anim"
          android:layout_width="25dp"
          android:layout_height="25dp"
          android:layout_gravity="center_vertical|right"
          android:background="@drawable/adj"/>
       
    </FrameLayout>
    
    <TextView 
        android:id="@+id/recorder_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginRight="3dp"
        android:layout_toLeftOf="@id/recorder_length"
        android:text=""
        android:textColor="#ff777777"/>

</RelativeLayout>

dialog的布局样式文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/dialog_loading_bg"
    android:gravity="center"
    android:orientation="vertical"
    android:padding="20dp"
    tools:context="com.example.weixin_record.MainActivity" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/dialog_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/recorder"
            android:visibility="visible" />

        <ImageView
            android:id="@+id/dialog_voice"
            android:layout_width="wrap_content"
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值