The camera drivers only support some preview sizes. In 2.0, you should
call getSupportedPreviewSizes to know the valid values and then call
setPreviewSize. In 1.6 and before, it's better just to call
getPreviewSize to know the preview size instead of changing it.

To achieve what you want, you should use other image views to block
the area of SurfaceView that you don't want the users see.

On Nov 16, 11:54 pm, Enrique López Mañas <eenriquelo...@gmail.com>
wrote:
> Hello all,
>
> I have been playing with Android for a couple of months, so I'm still
> kindof newbie on this. I've looking for previous questions like mine,
> but I was unable to find any proper solution. So here goes my
> question:
>
> I'm trying to draw aCameraPreview in a certain part of the screen
> (for instance, square upper-left). So what I suppose I should do is
> the following:
>
> //My main activity
>
> //Object preview, which extends from SurfaceView implements
> SurfaceHolder.Callback
> Preview camPreview;
>
> [...]
>
> setContentView(camPreview); //set preview as activity content
>
> And on the Preview Class I have the following lines:
>
> public void surfaceCreated(SurfaceHolder holder) {
>         // The Surface has been created, acquire thecameraand tell
>         // to draw.
>         mCamera =Camera.open();
>         try {
>         //Trying to set up the PreviewSize, to embed it into the upper-
> left square
>                Camera.Parameters parameters = mCamera.getParameters();
>                 parameters.setPreviewSize(50, 50);
>                 mCamera.setParameters(parameters);
>                 mCamera.setPreviewDisplay(holder);
>         } catch (IOException e) {
>                 // TODO Auto-generated catch block
>                 e.printStackTrace();
>         }
>
> }
>
> The preview is still occuping all the screen, so I bet I
> missunderstood something in the manuals :S. For the first touch with
> Android I found the views / layouts / organizational concepts pretty
> confusing, though.
>
> Does anyone have any suggestion about what I can check, in order to
> achieve it?
>
> Thank you in advance, and regards,
>
> Enrique

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to