本文整理了Java中android.view.SurfaceView.setLayoutParams()
方法的一些代码示例,展示了SurfaceView.setLayoutParams()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SurfaceView.setLayoutParams()
方法的具体详情如下:
包路径:android.view.SurfaceView
类名称:SurfaceView
方法名:setLayoutParams
暂无
代码示例来源:origin: pili-engineering/PLDroidPlayer
public void onVideoSizeChanged(int width, int height) {
Log.i(TAG, "onVideoSizeChanged: width = " + width + ", height = " + height);
// resize the display window to fit the screen
if (width != 0 && height != 0) {
float ratioW = (float) width / (float) mSurfaceWidth;
float ratioH = (float) height / (float) mSurfaceHeight;
float ratio = Math.max(ratioW, ratioH);
width = (int) Math.ceil((float) width / ratio);
height = (int) Math.ceil((float) height / ratio);
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(width, height);
layout.gravity = Gravity.CENTER;
mSurfaceView.setLayoutParams(layout);
}
}
};
代码示例来源:origin: daniulive/SmarterStreaming
Log.i(PLAY_TAG, "++PlayInflateLayout..");
playerSurfaceView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
代码示例来源:origin: daniulive/SmarterStreaming
Log.i(TAG, "++inflateLayout..");
sSurfaceView.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
代码示例来源:origin: stackoverflow.com
lp.height = screenHeight;
surfaceViewFrame.setLayoutParams(lp);
代码示例来源:origin: tony-Shx/Swface
private void setSurfaceSize() {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
int height = (int) (width * PREVIEW_WIDTH / (float)PREVIEW_HEIGHT);
RelativeLayout.LayoutParams params = new LayoutParams(width, height);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
mPreviewSurface.setLayoutParams(params);
mFaceSurface.setLayoutParams(params);
}
代码示例来源:origin: stackoverflow.com
if (VERSION.SDK_INT < VERSION_CODES.HONEYCOMB) {
final SurfaceView fakeView = new SurfaceView(this);
fakeView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
fakeView.setZOrderMediaOverlay(false);
final CameraView cameraView = (CameraView) this.findViewById(R.id.cameraview);
cameraView.setZOrderMediaOverlay(true);
cameraView.fakeView = fakeView;
}
代码示例来源:origin: googlesamples/android-MediaRouter
public void updateSize(int width, int height) {
int surfaceHeight = getWindow().getDecorView().getHeight();
int surfaceWidth = getWindow().getDecorView().getWidth();
ViewGroup.LayoutParams lp = mPresentationSurfaceView.getLayoutParams();
if (surfaceWidth * height < surfaceHeight * width) {
lp.width = surfaceWidth;
lp.height = surfaceWidth * height / width;
} else {
lp.width = surfaceHeight * width / height;
lp.height = surfaceHeight;
}
Log.i(TAG, "Presentation video rect is " + lp.width + "x" + lp.height);
mPresentationSurfaceView.setLayoutParams(lp);
}
}
代码示例来源:origin: Car-eye-team/Car-eye-device
@Override
public void onClick(View v) {
if (display) {
seekbarView.setVisibility(View.GONE);
playbarView.setVisibility(View.GONE);
display = false;
} else {
seekbarView.setVisibility(View.VISIBLE);
playbarView.setVisibility(View.VISIBLE);
pView.setVisibility(View.VISIBLE);
ViewGroup.LayoutParams lp = pView.getLayoutParams();
lp.height = LayoutParams.FILL_PARENT;
lp.width = LayoutParams.FILL_PARENT;
pView.setLayoutParams(lp);
display = true;
}
}
});
代码示例来源:origin: huangfangyi/YiChat
private void resizeSurfaceView() {
Point point;
if (cameraId == 0) {
point = backCameraSize.getFirst();
} else {
point = frontCameraSize.getFirst();
}
if (currentUsePoint != null && point.equals(currentUsePoint)) {
return;
} else {
currentUsePoint = point;
int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
int surfaceHeight = screenWidth * point.x / point.y;
if (surfaceview != null) {
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) surfaceview.getLayoutParams();
lp.width = screenWidth;
lp.height = surfaceHeight;
lp.addRule(13);
surfaceview.setLayoutParams(lp);
}
}
}
代码示例来源:origin: stackoverflow.com
lp.column=0;
lp.weight=0.05f;
mSurfaceView.setLayoutParams(lp);
代码示例来源:origin: qiubiteme/android_api_demos
@Override
public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) {
Resolution r = (Resolution) parent.getItemAtPosition(pos);
ViewGroup.LayoutParams lp = mSurfaceView.getLayoutParams();
if (getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE) {
mDisplayHeight = r.y;
mDisplayWidth = r.x;
} else {
mDisplayHeight = r.x;
mDisplayWidth = r.y;
}
lp.height = mDisplayHeight;
lp.width = mDisplayWidth;
mSurfaceView.setLayoutParams(lp);
}
代码示例来源:origin: li2/learning-android-open-source
@Override
public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) {
Resolution r = (Resolution) parent.getItemAtPosition(pos);
ViewGroup.LayoutParams lp = mSurfaceView.getLayoutParams();
if (getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE) {
mDisplayHeight = r.y;
mDisplayWidth = r.x;
} else {
mDisplayHeight = r.x;
mDisplayWidth = r.y;
}
lp.height = mDisplayHeight;
lp.width = mDisplayWidth;
mSurfaceView.setLayoutParams(lp);
}
代码示例来源:origin: runner365/android_rtmppush_sdk
private void InitAll() {
WindowManager wm = this.getWindowManager();
int width = wm.getDefaultDisplay().getWidth();
int height = wm.getDefaultDisplay().getHeight();
int iNewWidth = (int) (height * 3.0 / 4.0);
RelativeLayout rCameraLayout = (RelativeLayout) findViewById(R.id.cameraRelative);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
int iPos = width - iNewWidth;
layoutParams.setMargins(iPos, 0, 0, 0);
_mSurfaceView = (SurfaceView) this.findViewById(R.id.surfaceViewEx);
_mSurfaceView.getHolder().setFixedSize(HEIGHT_DEF, WIDTH_DEF);
_mSurfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
_mSurfaceView.getHolder().setKeepScreenOn(true);
_mSurfaceView.getHolder().addCallback(new SurceCallBack());
_mSurfaceView.setLayoutParams(layoutParams);
InitAudioRecord();
_SwitchCameraBtn = (Button) findViewById(R.id.SwitchCamerabutton);
_SwitchCameraBtn.setOnClickListener(_switchCameraOnClickedEvent);
RtmpStartMessage();//开始推流
}
代码示例来源:origin: small-dream/VideoRecord
/**
* 初始化画布
*/
private void initSurfaceView() {
final int w = DeviceUtils.getScreenWidth(this);
((RelativeLayout.LayoutParams) mBottomLayout.getLayoutParams()).topMargin = w;
int width = w;
int height = w * 4 / 3;
//
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) mSurfaceView
.getLayoutParams();
lp.width = width;
lp.height = height;
mSurfaceView.setLayoutParams(lp);
}
代码示例来源:origin: qiniu/qplayer-sdk
private void UpdateSurfaceViewPos(int nW, int nH) {
if (nW == 0 || nH == 0)
return;
RelativeLayout.LayoutParams lpView = (RelativeLayout.LayoutParams) m_svVideo.getLayoutParams();
RelativeLayout.LayoutParams lpLayout = (RelativeLayout.LayoutParams) m_layVideo.getLayoutParams();
if (m_nViewWidth == 0 || m_nViewHeight == 0) {
DisplayMetrics dm = this.getResources().getDisplayMetrics();
m_nViewWidth = lpLayout.width;
m_nViewHeight = lpLayout.height;
if (m_nViewWidth <= 0)
m_nViewWidth = dm.widthPixels;
if (m_nViewHeight <= 0)
m_nViewHeight = dm.heightPixels;
}
if (m_nViewWidth * nH > nW * m_nViewHeight) {
lpView.height = m_nViewHeight;
lpView.width = nW * m_nViewHeight / nH;
} else {
lpView.width = m_nViewWidth;
lpView.height = nH * m_nViewWidth / nW;
}
m_svVideo.setLayoutParams(lpView);
}
代码示例来源:origin: ysq1051838264/CustomCamera
/**
* 设置
*/
private void setupCamera(Camera camera) {
Camera.Parameters parameters = camera.getParameters();
List<String> focusModes = parameters.getSupportedFocusModes();
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
// Autofocus mode is supported 自动对焦
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
}
Camera.Size previewSize = CameraUtil.findBestPreviewResolution(camera);
parameters.setPreviewSize(previewSize.width, previewSize.height);
Camera.Size pictrueSize = CameraUtil.getInstance().getPropPictureSize(parameters.getSupportedPictureSizes(), 1000);
parameters.setPictureSize(pictrueSize.width, pictrueSize.height);
camera.setParameters(parameters);
int picHeight = CameraUtil.screenWidth * previewSize.width / previewSize.height;
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(CameraUtil.screenWidth, picHeight);
mSurfaceView.setLayoutParams(params);
}
代码示例来源:origin: xugaoxiang/VLCAndroidMultiWindow
lp.width = vidW;
lp.height = vidH;
mSurface.setLayoutParams(lp);
mSurface.invalidate();
代码示例来源:origin: lizhangqu/Camera
surfaceviewParams.width = heightPixels * 4 / 3;
surfaceviewParams.height = heightPixels;
mSurfaceView.setLayoutParams(surfaceviewParams);
代码示例来源:origin: googlesamples/android-MediaRouter
@Override
protected void updateSize() {
int width = getVideoWidth();
int height = getVideoHeight();
if (width > 0 && height > 0) {
if (mPresentation == null) {
int surfaceWidth = mLayout.getWidth();
int surfaceHeight = mLayout.getHeight();
// Calculate the new size of mSurfaceView, so that video is centered
// inside the framelayout with proper letterboxing/pillarboxing
ViewGroup.LayoutParams lp = mSurfaceView.getLayoutParams();
if (surfaceWidth * height < surfaceHeight * width) {
// Black bars on top&bottom, mSurfaceView has full layout width,
// while height is derived from video's aspect ratio
lp.width = surfaceWidth;
lp.height = surfaceWidth * height / width;
} else {
// Black bars on left&right, mSurfaceView has full layout height,
// while width is derived from video's aspect ratio
lp.width = surfaceHeight * width / height;
lp.height = surfaceHeight;
}
Log.i(TAG, "video rect is " + lp.width + "x" + lp.height);
mSurfaceView.setLayoutParams(lp);
} else {
mPresentation.updateSize(width, height);
}
}
}
代码示例来源:origin: NodeMedia/NodeMediaClient-Android
public void setRenderType(RenderType renderType) {
if (mCurrentRenderType == renderType)
return;
if (mCurrentRenderType == SURFACEVIEW) {
SurfaceView sv = (SurfaceView) renderView;
sv.getHolder().removeCallback(this);
removeView(renderView);
renderView = null;
} else if (mCurrentRenderType == TEXTUREVIEW) {
TextureView tv = (TextureView) renderView;
tv.setSurfaceTextureListener(null);
removeView(renderView);
renderView = null;
}
if (renderType == SURFACEVIEW) {
SurfaceView sv = new SurfaceView(mContext);
sv.getHolder().addCallback(this);
sv.setLayoutParams(deflp);
renderView = sv;
addView(renderView);
} else if (renderType == TEXTUREVIEW) {
TextureView tv = new TextureView(mContext);
tv.setSurfaceTextureListener(this);
tv.setLayoutParams(deflp);
renderView = tv;
addView(renderView);
}
mCurrentRenderType = renderType;
}
内容来源于网络,如有侵权,请联系作者删除!