I use a ready-made online example, can be used directly, but aspect inappropriate, now the mainstream is the big screen phone, so need to change.
Locate the Cameramanager class and change the method below
PublicRect Getframingrect () {Point screenresolution=configmanager.getscreenresolution (); if(Framingrect = =NULL) { if(Camera = =NULL) { return NULL; } intwidth = screenresolution.x * 3/5;//if (Width < min_frame_width) {//width = min_frame_width;//} else if (Width > max_frame_width) {//width = max_frame_width;// } intHeight = screenresolution.y * 3/5;//if (height < min_frame_height) {//height = min_frame_height;//} else if (height > max_frame_height) {//height = max_frame_height;// } /*custom, with a wide height of one of the narrow squares for the side length*/width= (width>height?)height:width); Height= (widthwidth:height); intLeftOffset = (screenresolution.x-width)/2;//int topoffset = (screenresolution.y-height)/2; intTopoffset = (screenresolution.y-height)/2-40;/*Custom, put on a little*/Framingrect=NewRect (LeftOffset, Topoffset, LeftOffset + width, Topoffset +height); LOG.D (TAG,"Calculated framing Rect:" +framingrect); } returnFramingrect; }
Download Link: http://download.csdn.net/detail/feijian_/8275179
Android Development modified camera scan Two-dimensional code box high width