【发布时间】:2011-09-30 10:32:55
【问题描述】:
我有一个 ViewFlipper,它只包含一个孩子(线性布局),我遇到的问题是当我切换视图时,它运行良好并显示下一个视图等等。但是动画并不顺利,我的意思是当前屏幕移动而下一个屏幕出现! 在这种情况下,当前屏幕会被移除并滑入下一个屏幕。
如何让当前屏幕滑开,让下一个屏幕滑入,同时在 ViewFlipper 中有一个孩子?我找遍了,找不到任何东西!
xml代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/layout">
<ViewFlipper
android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/dateView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
/>
<ListView
android:id="@+id/myListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
</ViewFlipper>
安卓代码:
case MotionEvent.ACTION_UP:{
currentX = event.getX();
if (Math.abs(currentX - downXValue) >= v.getWidth()/5){
if(currentX < downXValue){
calendar.add(Calendar.DAY_OF_MONTH, 1);
dateAdapter.notifyDataSetChanged();
todoAdapter.clear();
todoAdapter.notifyDataSetChanged();
vf.setInAnimation(v.getContext(), R.anim.push_left_in);
vf.setOutAnimation(v.getContext(), R.anim.push_left_out);
vf.showPrevious();
}
else{
calendar.add(Calendar.DAY_OF_MONTH, -1);
dateAdapter.notifyDataSetChanged();
todoAdapter.clear();
todoAdapter.notifyDataSetChanged();
vf.setInAnimation(v.getContext(), R.anim.push_right_in);
vf.setOutAnimation(v.getContext(), R.anim.push_right_out);
vf.showNext();
}
}
break;
}
最好的问候!
【问题讨论】:
标签: android android-linearlayout viewflipper