本文整理了Java中android.view.SurfaceView.layout()
方法的一些代码示例,展示了SurfaceView.layout()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SurfaceView.layout()
方法的具体详情如下:
包路径:android.view.SurfaceView
类名称: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);
内容来源于网络,如有侵权,请联系作者删除!