I cannot use setContentView and hence inflating is the only way (this view will go on top of cordova activity). I wish to add a view of a strict size on top and not occupying full screen. This is what I am doing
@Override
public void onCreate(Bundle savedInstanceState) {
final ScrollView inflate = new ScrollView(this);
final LinearLayout main = new LinearLayout(this);
final SurfaceView surfaceView = new SurfaceView(this);
final SurfaceHolder holder = surfaceView.getHolder();
WindowManager mW = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
int screenWidth = mW.getDefaultDisplay().getWidth();
int screenHeight = mW.getDefaultDisplay().getHeight();
surfaceView.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenHeight));
holder.addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder holder) {
try {
camera = getCamera();
camera.setPreviewDisplay(holder);
camera.setDisplayOrientation(90);
camera.startPreview();
} catch (IOException e) {
Log.i("Lucy", e.getMessage());
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
}
});
main.addView(surfaceView);
final TextView text = new TextView(this);
text.setText("Scanning.....");
text.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
main.addView(text);
inflate.addView(main);
inflate.setFillViewport(true);
addContentView(inflate, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 200, 0));
}
The camera still occupies the full screen. I want the view inflate to just occupy top with height 200. What am i doing it wrong. Doing
surfaceView.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, 200));
solves the problem but it puts the whole camera feed in 200 pixels and the camera is not clear. hence this wont help.
0 comments:
Post a Comment