首先,当我按住录制按钮时,它将开始录制.这部分工作得很好.
其次,当我将手指朝后方向移动到垃圾桶时,然后“文本视图幻灯片取消”应该向后滑动并且录制应该暂停.在某一点之后我将执行垃圾桶打开动画.但是,如果我向前滑动,如果向前滑动则应将文本视图设置在其原始位置,并且应再次播放录音.
我的问题:我没有得到任何帮助如何准确地滑动文本视图.
我也从https://github.com/sarathnk/Audio这里得到了帮助但是我无法达到预期的效果.
这是我的Java代码:
holdtoRecord = (ImageVIEw) findVIEwByID(R.ID.hold);slIDer = (TextVIEw) findVIEwByID(R.ID.slIDe);holdtoRecord.setontouchListener(new VIEw.OntouchListener() { @OverrIDe public boolean ontouch(VIEw v,MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { // start recording. mVIDeoVIEw.pause(); onHold(); return true; } if (event.getAction() == MotionEvent.ACTION_UP) { // Stop recording and save file mVIDeoVIEw.start(); offHold(); return true; } if (event.getAction() == MotionEvent.ACTION_MOVE) { }解决方法 尝试使用此代码即可.
int xPos_terminal = 100; int xPos_DragInitial = 0;hold.setontouchListener(new VIEw.OntouchListener() { @OverrIDe public boolean ontouch(VIEw vIEw,MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { // start recording. xPos_DragInitial = (int) motionEvent.getX(); xPos_SlIDerOriginal = (int) slIDer.getX(); int xPos_Trash = (int) trash_cap.getX(); Log.e("original",String.valueOf(xPos_Trash)); return true; } if (motionEvent.getAction() == MotionEvent.ACTION_UP) { return true; } if (motionEvent.getAction() == MotionEvent.ACTION_MOVE) { int xPos_current = (int) motionEvent.getX(); //Handling of SlIDetoCancel VIEw String slIDetoVIEwMsg = ""; if(xPos_current < xPos_DragInitial) { //left DIRECTION Log.e("----- left DIRECTION --","S"); if(xPos_SlIDerOriginal > (xPos_terminal)) { slIDetoVIEwMsg = "Animate SlIDetoCancel vIEw to Reduce its X"; lp = new relativeLayout.LayoutParams(relativeLayout.LayoutParams.WRAP_CONTENT,relativeLayout.LayoutParams.WRAP_CONTENT); int newXOfSlIDer = (int) slIDer.getX(); newXOfSlIDer -= 2; lp.setmargins(newXOfSlIDer,(int) slIDer.getY(),0); slIDer.setLayoutParams(lp); } else { slIDetoVIEwMsg = "Donot Animate SlIDetoCancel vIEw"; } } else { //RIGHT DIRECTION Log.e("---- RIGHT DIRECTION --","r"); if((int)slIDer.getX() < xPos_SlIDerOriginal) { slIDetoVIEwMsg = "Animate SlIDetoCancel vIEw to increase X"; int newXOfSlIDer = (int) slIDer.getX(); newXOfSlIDer += 2; lp.setmargins(newXOfSlIDer,0); slIDer.setLayoutParams(lp); } else { slIDetoVIEwMsg = "Donot Animate SlIDetoCancel VIEw"; } } Log.e("x",slIDetoVIEwMsg); //Handling of Delet button if (xPos_current < (xPos_terminal)) { //Animate Delete button to open } else { //Animate Delet button To Close } //chnage xPosInitial to xPosCurrent to get actual direction xPos_DragInitial = xPos_current; return true; } return false; } }); }总结
以上是内存溢出为你收集整理的在Android中滑动以取消动画全部内容,希望文章能够帮你解决在Android中滑动以取消动画所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)