简单模拟微信长按语音发送效果
来源:互联网 发布:linux piwik安装详解 编辑:程序博客网 时间:2024/03/29 17:59
在此不多说,直接上代码吧:
简单的布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
<TextView
android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="80dip"
android:layout_marginTop="30dip"
android:text="松开取消语音发送"
android:gravity="center"
android:textSize="20sp"
android:textColor="@android:color/black"
android:visibility="gone"
/>
<Button
android:id="@+id/click"
android:layout_width="fill_parent"
android:layout_height="80dip"
android:text="长按说话"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
实现代码:
import android.R.integer;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
public class ClickSendActivity extends Activity {
private int height;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.click);
View click=findViewById(R.id.click);
final TextView tv=(TextView) findViewById(R.id.tv);
click.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
tv.setVisibility(View.VISIBLE);
tv.setText("手指上滑取消发送");
break;
case MotionEvent.ACTION_MOVE:
if(event.getY()<0){
tv.setText("手指松开取消发送");
}else{
tv.setText("手指上滑取消发送");
}
break;
case MotionEvent.ACTION_UP:
if(event.getY()<0){//因为getY是相对控件本身的坐标,所以当<0时,手指已不再此控件上
Toast.makeText(ClickSendActivity.this, "取消发送", 1).show();
}else {
Toast.makeText(ClickSendActivity.this, "正在发送", 1).show();
}
break;
default:
break;
}
return true;
}
});
}
}
- 简单模拟微信长按语音发送效果
- Android,长按发送语音,简单模拟微信长按语音发送效果
- 【Android应用开发】Instrumentation简单的模拟按键发送消息
- jQuery动态绑定事件(简单模拟二级联动效果)
- 【转】jQuery实现的简单文字提示效果模拟title
- 用Tween动画简单模拟果冻按钮效果
- Android LightingColorFilter 模拟简单的光照效果的
- 解决android 长按语音操作 弹出语音层 点击其他的按钮会影响语音层的时间
- java模拟发送request
- 模拟发送http请求
- 模拟按键发送消息
- 模拟发送短信
- 模拟短信发送按钮
- android模拟发送键值
- 模拟“发送短信”按钮
- 模拟QQ发送消息
- day03-模拟手机短信发送
- 5.模拟短信发送
- 项目应用中JQUERY+CSS
- 偷个空,写个博客——各种沟通各种纠结
- 苹果平台上的媒体流播放技术HLS
- Dreamweaver下拉菜单全攻略
- ios 版 qq 聊天记录的导出
- 简单模拟微信长按语音发送效果
- Visual Studio 开发环境中无法浏览页面/无法进行调试
- chromium r197479g版本编译运行
- 网页上显示天气、IP情况
- XMPP——Smack[1]连接、登陆及账户操作
- 哈夫曼树与哈夫曼编码
- CodeForces 276E - Little Girl and Problem on Trees 区间更新..N+1个线段树
- 程序的局部变量 全局变量 动态申请数据分别存储在什么地方?
- Linux检测网络故障以及恢复网络的方法