我發現了幾個關於如何獲得3D動畫以在ViewFlipper中翻轉視圖的指南。他們都使用相機和旋轉來實現效果。我用這個:http://code.google.com/p/android-3d-flip-view-transition/ - 包裝來實現結果 - 並且一切正常。也就是說,就視覺翻轉而言。在android上使用3D視圖filp - 在翻轉後沒有onClick
什麼不工作,雖然是完成翻蓋的按鈕。感覺好像所有的onClick事件都沒有收到,或者在翻轉完成後被忽略。這是我最基本的例子。
XML:
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/selector_flipper">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/playing_field"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Flip"
android:onClick="flipView" />
</LinearLayout>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tag_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"/>
</ViewFlipper>
活動:
public class SelectorActivity extends Activity {
private ViewFlipper flipper;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.selector);
flipper = (ViewFlipper)this.findViewById(R.id.selector_flipper);
}
/**
* @see android.app.Activity#onKeyDown(int, android.view.KeyEvent)
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && tagList.getVisibility() == View.VISIBLE)
flipView(null);
else
return super.onKeyDown(keyCode, event);
}
public void flipView(View v) {
AnimationFactory.flipTransition(flipper, FlipDirection.RIGHT_LEFT);
}
}
在創建活動中,我可以點擊 「翻轉」 按鈕 - 和視圖翻轉,因爲我希望它。然後,我可以按下手機上的「返回」按鈕 - 然後按照我想要的方式翻轉。但是現在我無法再點擊按鈕 - 所有的點擊都被忽略。
任何人都可以幫我解決這個問題的底部嗎?非常感激!
P.S.我嘗試了其他包裝,甚至自己編碼相同的動畫 - 但結果始終如一!翻轉後點擊不起作用!
可能是一個錯誤?你有沒有嘗試在java代碼中分配一個onClickListener而不是xml'onClick'?這可能是視圖沒有被正確地回收,或者它可能以某種方式變得不可聚焦。 – 2012-03-20 16:58:39
@John:謝謝你的評論。是的,我確實在代碼中分配了onClickListener - 我開始使用它。當我遇到這個問題時,我將它分配給了XML--這既是爲了簡化代碼,也是嘗試另一種方式。這種看法更可能以某種方式變得無法集中 - 是否有什麼可以做到的呢? – 2012-03-20 17:10:13