android.view.SurfaceView.layout()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中android.view.SurfaceView.layout()方法的一些代码示例,展示了SurfaceView.layout()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SurfaceView.layout()方法的具体详情如下:
包路径:android.view.SurfaceView
类名称:SurfaceView
方法名:layout

SurfaceView.layout介绍

暂无

代码示例

代码示例来源:origin: journeyapps/zxing-android-embedded

@SuppressLint("DrawAllocation")
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
  containerSized(new Size(r - l, b - t));
  if(surfaceView != null) {
    if (surfaceRect == null) {
      // Match the container, to reduce the risk of issues. The preview should never be drawn
      // while the surface has this size.
      surfaceView.layout(0, 0, getWidth(), getHeight());
    } else {
      surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom);
    }
  } else if(textureView != null) {
    textureView.layout(0, 0, getWidth(), getHeight());
  }
}

代码示例来源:origin: stackoverflow.com

public class CroppedCameraPreview extends ViewGroup {
 private SurfaceView cameraPreview;
 public CroppedCameraPreview( Context context ) {
  super( context );
  // i'd probably create and add the SurfaceView here, but it doesn't matter
 }
 @Override
 protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec ) {
  setMeasuredDimension( croppedWidth, croppedHeight );
 }
 @Override
 protected void onLayout( boolean changed, int l, int t, int r, int b ) {
  if ( cameraPreview != null ) {
   cameraPreview.layout( 0, 0, actualPreviewWidth, actualPreviewHeight );
  }
 }
}

代码示例来源:origin: stackoverflow.com

public class CroppedCameraPreview extends ViewGroup {
 private SurfaceView cameraPreview;
 public CroppedCameraPreview( Context context ) {
  super( context );
  // i'd probably create and add the SurfaceView here, but it doesn't matter
 }
 @Override
 protected void onMeasure( int widthMeasureSpec, int heightMeasureSpec ) {
  setMeasuredDimension( croppedWidth, croppedHeight );
 }
 @Override
 protected void onLayout( boolean changed, int l, int t, int r, int b ) {
  if ( cameraPreview != null ) {
   cameraPreview.layout( 0, 0, actualPreviewWidth, actualPreviewHeight );
  }
 }
}

代码示例来源:origin: stackoverflow.com

public class BarcodeCameraPreview extends ViewGroup {

private SurfaceView mSurfaceView;

public BarcodeCameraPreview(final Context context, AttributeSet attrs) {
  super(context, attrs);

  mSurfaceView = new SurfaceView(context);
  mSurfaceView.getHolder().addCallback(new SurfaceCallback());
  addView(mSurfaceView);
}

  @Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
    // crop view
    int actualPreviewWidth = getResources().getDisplayMetrics().widthPixels;
    int actualPreviewHeight = getResources().getDisplayMetrics().heightPixels;

    if (mSurfaceView != null) {
      mSurfaceView.layout(0, 0, actualPreviewWidth, actualPreviewHeight);
    }
  }

// camera methods

}

代码示例来源:origin: stackoverflow.com

mSurfaceView.layout(0, 0, actualPreviewWidth, actualPreviewHeight);

相关文章