我做了一个示例应用程序来翻转viewflipper中的不同布局。Android的主屏幕像设置child.setvisibility(View.Visible)效果闪烁的问题
XML基本上是(伪代码)
<ViewFlipper>
<LinearLayout><TextView text:"this is the first page" /></LinearLayout>
<LinearLayout><TextView text:"this is the second page" /></LinearLayout>
<LinearLayout><TextView text:"this is the third page" /></LinearLayout>
</ViewFlipper>
而且在Java代码中,
public boolean onTouchEvent(MotionEvent event)
case MotionEvent.ACTION_DOWN {
oldTouchValue = event.getX()
} case MotionEvent.ACTION_UP {
//depending on Direction, do viewFlipper.showPrevious or viewFlipper.showNext
//after setting appropriate animations with appropriate start/end locations
} case MotionEvent.ACTION_MOVE {
//Depending on the direction
nextScreen.setVisibility(View.Visible)
nextScreen.layout(l, t, r, b) // l computed appropriately
CurrentScreen.layout(l2, t2, r2, b2) // l2 computed appropriately
}
上述伪代码在屏幕上拖动(就像家里的时候效果很好移动内部viewflipper linearlayouts屏幕)。
问题是,当我做nextScreen.setVisibility(View.VISIBLE)。当下一个屏幕被设置为可见时,它会在屏幕上闪烁,然后移动到合适的位置。 (我想它是在0位置可见的。)
有没有办法加载下一个屏幕而不会在屏幕上闪烁?我想让它在屏幕之外加载(显示),以免闪烁。
非常感谢您的时间和帮助!