I have this book and I love it! :)
There is a place in the book (ch.11, page 390, middle of page) where it says and I quote:
"A SurfaceView can be used in exactly the same way as any View-derived class. You can apply animations and place them in your layouts as you would any other view."
But I'm not having any luck doing this with my SurfaceView.
Here is my java code:
Code:
setContentView(R.layout.takepic);
//setContentView(camPreview); //set preview as activity content
camSurface = (SurfaceView) findViewById(R.id.camsurface);
Here is my layout code:
Code:
<SurfaceView android:id="@+id/camsurface"
android:layout_marginTop="20dip"
android:layout_width="240px"
android:layout_height="160px"
android:layout_gravity="center_horizontal"/>
If I use the
setContentView(camPreview);, my camera preview appears on the screen, but not in my layout.
If I use the
camSurface = (SurfaceView) findViewById(R.id.camsurface);, my layout appears, but my camera preview does not show up in the layout, I just get a black area where it shoud be. Can anyone help please?!