0
我在我的應用程序中使用了動畫,並且我使用的動畫是slide_left和slide_right.But問題是,向左滑動時顯示的動畫是光滑的,但是當我向右滑動時,動畫不是一帆風順的顯示,而滑動left.So爲什麼這些問題occurs.I有送你我的代碼,請檢查是否有任何錯誤。對於slide_left.xml文件顯示動畫效果的問題
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="100%p" android:toXDelta="0"
android:duration="@android:integer/config_longAnimTime" />
</set>
代碼slide_right.xml的代碼
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="-150%p" android:toXDelta="0"
android:duration="@android:integer/config_longAnimTime" />
</set>
代碼java文件
public boolean onTouch(View v, MotionEvent e)
{
switch (e.getAction())
{
case MotionEvent.ACTION_DOWN:
{
//store the X value when the user's finger was pressed down
m_downXValue = e.getX();
break;
}
case MotionEvent.ACTION_UP:
{
//Get the X value when the user released his/her finger
float currentX = e.getX();
// going forwards: pushing stuff to the left
if (m_downXValue > currentX && currentX < 0)
{
ViewFlipper vf = (ViewFlipper) findViewById(R.id.flipview);
vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_left));
}
// going backwards: pushing stuff to the right
if (m_downXValue < currentX && currentX > 100)
{
ViewFlipper vf = (ViewFlipper) findViewById(R.id.flipview);
vf.setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_right));
}
break;
}
}
return true;
}
把這些內部 或外部 –
AndroidDev
現在,我會改變我的代碼...... 使用此代碼 –
左側滑動的方式是ok..but的方式右側幻燈片不行。 – AndroidDev