介绍
这篇文章将为大家详细讲解有关Android怎么实现微信聊天语言点击喇叭动画效果,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
微信聊天界面点击语音时,喇叭的动画效果,下面上代码,该类是控制背景变化的工具类,不涉及语音录制和播放。
图片资源:
package xxx; import handler; import android.widget.ImageView; import xxx.R; import java.util.Timer; import java.util.TimerTask; public class  VoicePlayingBgUtil { private 才能Handler 处理程序; private 才能;ImageView  imageView; private 才能;ImageView  lastImageView; private 才能Timer Timer =, new 计时器(); private 才能;TimerTask  timerTask; private 才能;int 我; private 才能int modelType =, 1;//类型 private 才能,int [], leftVoiceBg =, new int [], {R.drawable.gray1的不同之处是,R.drawable.gray2, R.drawable.gray3 }; private 才能,int [], rightVoiceBg =, new int [], {R.drawable.green1的不同之处是,R.drawable.green2, R.drawable.green3 }; private 才能,int [], collectVoiceBg =, new int [], {R.drawable.collect_voice_1的不同之处是,R.drawable.collect_voice_2, R.drawable.collect_voice_3 }; public 才能;VoicePlayingBgUtil (Handler 处理程序),{ ,,,超级(); ,,,this.handler =,处理程序; ,,} public 才能;void  voicePlay (), { ,,,if (imageView ==, null), { ,,,,,返回; ,,,} ,,,小姐:=,0; ,,,timerTask =, new TimerTask (), { ,,,,@Override ,,,,,public void 运行(),{ ,,,,,,,if (imageView !=, null), { ,,,,,,,,,if (==modelType 1), { ,,,,,,,,,,,changeBg (leftVoiceBg[小姐:%,3),假); ,,,,,,,,,}else 如果(modelType==2) { ,,,,,,,,,,,changeBg (rightVoiceBg[小姐:%,3),假); ,,,,,,,,,}else 如果(modelType==3) { ,,,,,,,,,,,changeBg (collectVoiceBg[小姐:%,3),假); ,,,,,,,,,} ,,,,,,,} ,,,,,,,else { ,,,,,,,,,返回; ,,,,,,,} ,,,,,,,我+ +; ,,,,,} ,,,}; ,,,timer.schedule (timerTask, 0, 500); ,,} public 才能;void  stopPlay (), { ,,,lastImageView =, imageView; ,,,if (lastImageView !=, null), { ,,,,,switch (modelType), { ,,,,,,,case 1: ,,,,,,,,,changeBg (R.drawable.gray3,,真的); ,,,,,,,,,休息; ,,,,,,,case 2: ,,,,,,,,,changeBg (R.drawable.green3,,真的); ,,,,,,,,,休息; ,,,,,,,case 3: ,,,,,,,,,changeBg (R.drawable.collect_voice_3,,真的); ,,,,,,,默认值: ,,,,,,,,,changeBg (R.drawable.gray3,,真的); ,,,,,,,,,休息; ,,,,,} ,,,,,if (timerTask !=, null), { ,,,,,,,timerTask.cancel (); ,,,,,} ,,,} ,,} private 才能;void  changeBg (final int id, final boolean isStop), { ,,,handler.post (new Runnable (), { null null null null null null null null null null null null null null null null null null null null null null null nullAndroid怎么实现微信聊天语言点击喇叭动画效果