You can animate another view on top of a SurfaceView, you just cannot animate the SurfaceView itself.
On Tue, Sep 20, 2011 at 12:51 AM, MobileVisuals <[email protected]>wrote: > Thanks for the info, I have spent many hours investigating this issue > and now I finally know what the problem is. My app has a standard 2d > menu. It is possible to view different 3d visual effects from the > menu. The 3d visual effects are rendered in a GLSurfaceView. That > class extends SurfaceView. > > You say that SurfaceView should not be used in a ViewFlipper. How can > I implement my app if I can't use SurfaceView or GLSurfaceView? Which > type of view should I use for the ViewFlipper? Can I render the 3d > visual effects with other views than GLSurfaceView? > > Or shouldn't I use a ViewFlipper at all? If not, how can I then switch > between the 2d and the 3d rendering? > > On Sep 19, 7:37 pm, Dianne Hackborn <[email protected]> wrote: > > Don't use a SurfaceView in a ViewFlipper. > > > > Nor a ListView. > > > > SurfaceView is a *very* *special* view. As it says, what it does is > create > > a completely separate surface (a.k.a. window) that is associated with > your > > main window. This window is positioned behind the main window, and a > hole > > punched through your main window to see the surface behind. > > > > By its nature, this makes the interaction between the surface of the > surface > > view and the main view hierarchy limited. > > > > The purpose of SurfaceView is to present static things like video > playback > > or a game playfield in its own surface so that it can draw outside of the > > normal view hierarchy update model (and use OpenGL drawing, different > color > > spaces, etc). It is not to give a tight integration with the rest of the > > view hierarchy. > > > > You should essentially think of it as an overlay, because really that is > > what it is. > > > > On Mon, Sep 19, 2011 at 10:29 AM, MobileVisuals < > [email protected]>wrote: > > > > > > > > > My app uses a ViewFlipper. It is possible to flip between the views > > > without problems at first.But after switching to another app and then > > > switching back to the ViewFlipper app, it is not possible to flip > > > between the views. One of the views is always displayed as just a > > > black screen. > > > > > I have investigated the reason for this, using the simplest possible > > > SurfaceView. It is still the same problem. > > > It is not a thread problem, I see that the onDraw method is called > > > like it should. What is the reason for this? Doesn't the ViewFlipper > > > class support SurfaceView like it should? > > > > > I got the code for the SurfaceView from the basic tuturial: > > > > >http://www.edu4java.com/androidgame/androidgame2.html > > > > > and the code for the View flipper from Mark Murphys View flipper > > > tutorial: > > > > >https://github.com/commonsguy/cw-android/tree/master/Fancy/Flipper1 > > > > > This is my code: > > > ----------------------------- > > > > > public class FlipperDemo2 extends Activity { > > > > > ViewFlipper flipper; > > > > > @Override > > > public void onCreate(Bundle icicle) { > > > super.onCreate(icicle); > > > setContentView(R.layout.main); > > > > > flipper=(ViewFlipper)findViewById(R.id.details); > > > GameView lv=new GameView(this.getApplicationContext(),true); > > > flipper.addView(lv, > > > new ViewGroup.LayoutParams( > > > ViewGroup.LayoutParams.FILL_PARENT, > > > ViewGroup.LayoutParams.FILL_PARENT)); > > > GameView lv2=new GameView(this.getApplicationContext(),false); > > > flipper.addView(lv2, > > > new ViewGroup.LayoutParams( > > > ViewGroup.LayoutParams.FILL_PARENT, > > > ViewGroup.LayoutParams.FILL_PARENT)); > > > flipper.setFlipInterval(2000);//2000 > > > flipper.startFlipping(); > > > } > > > } > > > ---------------------------------- > > > > > public class GameView extends SurfaceView { > > > > > private SurfaceHolder holder; > > > boolean blue; > > > > > public GameView(Context context,boolean _blue) { > > > > > super(context); > > > holder = getHolder(); > > > blue=_blue; > > > holder.addCallback(new SurfaceHolder.Callback() { > > > > > @Override > > > public void surfaceDestroyed(SurfaceHolder holder) { > > > > > } > > > > > @Override > > > public void surfaceCreated(SurfaceHolder holder) { > > > > > Canvas c = holder.lockCanvas(null); > > > onDraw(c); > > > holder.unlockCanvasAndPost(c); > > > > > } > > > > > @Override > > > public void surfaceChanged(SurfaceHolder holder, int > > > format, int width, int height) { > > > } }); > > > } > > > > > @Override > > > > > protected void onDraw(Canvas canvas) { > > > > > if(blue) > > > canvas.drawColor(Color.YELLOW); > > > else > > > canvas.drawColor(Color.GREEN); > > > } > > > > > } > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to > [email protected] > > > To unsubscribe from this group, send email to > > > [email protected] > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en > > > > -- > > Dianne Hackborn > > Android framework engineer > > [email protected] > > > > Note: please don't send private questions to me, as I don't have time to > > provide private support, and so won't reply to such e-mails. All such > > questions should be posted on public forums, where I and others can see > and > > answer them. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Romain Guy Android framework engineer [email protected] -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

