我一直試圖實現ViewFlipper及其翻譯動畫。我可以參考很多頁面,但不管我嘗試了多少次,我都看不到動畫曾經發生過。下面是我的項目,目前沒有看到翻譯動畫,但如果我註釋掉vf.setOutAnimation ...部分,動畫動畫突然開始工作。 ...爲什麼?Android - inAnimation適用於ViewFlipper,但outAnimation不是
package com.example.testview;
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import android.widget.ViewFlipper;
public class TestViewActivity extends Activity implements OnTouchListener {
private ViewFlipper vf;
private float firstTouchX;
private float leaveTouchX;
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
vf = (ViewFlipper) findViewById(R.id.viewFlipper1);
vf.setOnTouchListener(this);
}
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
firstTouchX = event.getX();
break;
case MotionEvent.ACTION_UP:
leaveTouchX = event.getX();
if (this.firstTouchX - 50f > leaveTouchX) {
vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.right_in));
vf.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.left_out));
vf.showNext();
}
if (this.firstTouchX + 50f < leaveTouchX) {
vf.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.left_in));
vf.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.right_out));
vf.showPrevious();
}
break;
}
return true;
}
}
RES /動畫/ left_in.xml:
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="350"
android:fromXDelta="-100%p"
android:toXDelta="0%p"
android:fromYDelta="0%p"
android:toYDelta="0%p">
</translate>
RES /動畫/ left_out.xml:
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="350"
android:fromXDelta="0%p"
android:toXDelta="-100%p"
android:fromYDelta="0%p"
android:toYDelta="0%p">
</translate>
RES /動畫/ right_in.xml:
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="350"
android:fromXDelta="100%p"
android:toXDelta="0%p"
android:fromYDelta="0%p"
android:toYDelta="0%p">
</translate>
res/anim/right_out.xml:
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="350"
android:fromXDelta="0%p"
android:toXDelta="100%p"
android:fromYDelta="0%p"
android:toYDelta="0%p">
</translate>
RES /佈局/ main.xml中
<?xml version="1.0" encoding="utf-8"?>
<ViewFlipper
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewFlipper1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<include
android:id="@+id/first"
layout="@layout/first" />
<include
android:id="@+id/second"
layout="@layout/second" />
<include
android:id="@+id/third"
layout="@layout/third" />
</ViewFlipper>
first.xml/second.xml/third.xml(只有自己圖片ID不同)
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/img">
</ImageView>
BIG EDIT:我只是建立一個基於我的文章的小項目,它似乎工作......也許通過省略一些代碼,我認爲沒有必要開始討論導致我的問題的過程....我真的很抱歉,如果有人做了一個嘗試nswer。我會做更多的調查,並希望我可以發佈可用於以後參考的細分,除非mods刪除此問題。
BIG EDIT2:今天我再次嘗試,並且它不工作,大概是因爲我使用了Android ARM 2.2 Emulator。一旦我切換到ARM/Inter 2.3.3,它就可以工作。
http://stackoverflow.com/questions/8786435/achartengine-graph-using-two-y-axis –