开发者

Cannot move preview image with Android 2.3 (works in 2.2)

I have a simple photo taking application that has the following design:

[Consider the landscape mode for simplicity]

  1. On the left side there are a some buttons
  2. On the rest of the surface (the right side) I put the camera image preview

The resolution of the image is the same as the screen dimensions. For example if I have a 800x480 resolution of the screen the image has also the 800x480 resolution.

What I want to do is to move the image preview into the right side. By moving I mean the following:

Let's say that my resolution is 800x480. The left side (with buttons) has a size of 200 pixels. That means there are 600 pixels left for the image preview while the image is 800 pixels wide (800x480). This means that I can move the image on the x axis by 200 pixels (at most - that's nOffset variable below). On Android 2.2 this worked very well with the use of the following code:

SurfaceView cameraView;
....
cameraView.setLayoutParams(new AbsoluteLayout.LayoutParams(
                                  surfaceWidth, surfaceHeight, 
                                  nOffset, 0)
);

My questions are:

    开发者_JAVA百科
  • What's wrong with this code in 2.3 while in 2.2 it works well?
  • Is there a better way to move the preview image into a screen area?

Thanks for any suggestion and alternatives,

Iulian

PS: cameraView is under another surface which has set on it

holder.setFormat(PixelFormat.TRANSLUCENT);
setZOrderOnTop(true);


All our tests show that this is an Android 2.3 issue. The image cannot be moved but instead it is stretched when we try to do the things that work on Android 2.2.

This is the result of our investigation; it's clearly not expected and comes somehow as a surprising "regression".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜