Android如何实现滑动提交?

How to realize a Swipe to submit on Android?

我想为 Android 上的提交制作动画:

有人知道如何实现吗?

The idea is to drag (horizontal) a View in a ViewGroup (LinearLayout) and be able to recover the position.

使用自定义 seekbar

设置您自己的背景和图标。

完成 seekbarseekbar.setVisibility(View.GONE);circle.setVisibility(View.VISIBLE);

的滑动
  <SeekBar  
    android:id="@+id/seekBar1"  
    android:layout_width="match_parent"  
    android:layout_height="wrap_content"  

    android:layout_centerHorizontal="true"  
    android:layout_marginTop="16dp" />  

使用

android:thumb="@drawable/drag_thumb"

@drawable/drag_thumb 替换为您的拇指可绘制对象

 android:progressDrawable="@layout/custom_seekbar_layout"

创建自己的背景

 android:max="YOUR_TOTAL_PROGRESS"  <--replace YOUR_TOTAL_PROGRESS with your int -->

让你的classimplements OnSeekBarChangeListener

 seekBar=(SeekBar)findViewById(R.id.seekBar1);  
    seekBar.setOnSeekBarChangeListener(this);  

现在管理活动

@Override  
public void onProgressChanged(SeekBar seekBar, int progress,  
        boolean fromUser) {  
    Toast.makeText(getApplicationContext(),"seekbar progress: "+progress, Toast.LENGTH_SHORT).show();  
   if(progress == YOUR_TOTAL_PROGRESS)
   {
        seekbar.setVisibility(View.GONE);   
        circle.setVisibility(View.VISIBLE);
   }
}  
@Override  
public void onStartTrackingTouch(SeekBar seekBar) {  
    Toast.makeText(getApplicationContext(),"seekbar touch started!", Toast.LENGTH_SHORT).show();  
}  
@Override  
public void onStopTrackingTouch(SeekBar seekBar) {  
    Toast.makeText(getApplicationContext(),"seekbar touch stopped!", Toast.LENGTH_SHORT).show();  
    if (seekBar.getProgress() < YOUR_TOTAL_PROGRESS) {
        seekBar.setProgress(0);
    }
}  

seekbar 的完整幻灯片上,您可以为包含附加信息(显示 "Transfer Successful and contains button at bottom")的布局应用从下到上的过渡。

slide_in_top.xml :

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
 android:toYDelta="0%p"
android:duration="@android:integer/config_longAnimTime" />

slide_out_top.xml :

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:toYDelta="100%p"
android:duration="@android:integer/config_longAnimTime" />