首页 > 移动平台 > 详细

android开发修改相机扫描二维码框的高宽

时间:2014-12-18 20:18:22      阅读:752      评论:0      收藏:0      [点我收藏+]

我用的是网上一个现成的例子,可以直接用,但是高宽不合适,现在主流都是大屏幕手机了,所以需要更改。

找到CameraManager 类,更改下面的方法

public Rect getFramingRect() {
    Point screenResolution = configManager.getScreenResolution();
    if (framingRect == null) {
      if (camera == null) {
        return null;
      }
      int width = screenResolution.x * 3 / 5;
//      if (width < MIN_FRAME_WIDTH) {
//        width = MIN_FRAME_WIDTH;
//      } else if (width > MAX_FRAME_WIDTH) {
//        width = MAX_FRAME_WIDTH;
//      }
      int height = screenResolution.y * 3 / 5;
//      if (height < MIN_FRAME_HEIGHT) {
//        height = MIN_FRAME_HEIGHT;
//      } else if (height > MAX_FRAME_HEIGHT) {
//        height = MAX_FRAME_HEIGHT;
//      }
        /* 自定义,以宽高其中一个窄的为正方形的边长 */
        width = (width>height?height:width);
        height = (width<height?width:height);
      int leftOffset = (screenResolution.x - width) / 2;
//      int topOffset = (screenResolution.y - height) / 2;
        int topOffset = (screenResolution.y - height) / 2 - 40;  /* 自定义,放上一点 */
      framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
      Log.d(TAG, "Calculated framing rect: " + framingRect);
    }
    return framingRect;
  }

 

 

下载链接:http://download.csdn.net/detail/feijian_/8275179

android开发修改相机扫描二维码框的高宽

原文:http://www.cnblogs.com/feijian/p/4172561.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!