int screenHeight = getWindowManager().getDefaultDisplay().getHeight(); float screenProportion = (float) screenWidth / (float) screenHeight; android.view.ViewGroup.LayoutParams lp = surfaceViewFrame.getLayoutParams();
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); } }
@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; } } });
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); } } }
@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); }
@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); }
/** * 初始化画布 */ 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); }
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); }
holder.setFixedSize(finalWidth, finalHeight); ViewGroup.LayoutParams lp = mSurface.getLayoutParams(); lp.width = finalWidth; lp.height = finalHeight;
LayoutParams lp = mSurface.getLayoutParams(); lp.width = vidW; lp.height = vidH;
LayoutParams lp = mSurface.getLayoutParams(); lp.width = vidW; lp.height = vidH;
int screenHeight = getWindowManager().getDefaultDisplay().getHeight(); float screenProportion = (float) screenWidth / (float) screenHeight; android.view.ViewGroup.LayoutParams lp = surfaceViewFrame.getLayoutParams();
@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); } } }
RelativeLayout.LayoutParams surfaceviewParams = (RelativeLayout.LayoutParams) mSurfaceView.getLayoutParams(); surfaceviewParams.width = heightPixels * 4 / 3; surfaceviewParams.height = heightPixels;
screenHeight = size.y; FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mSurfaceView.getLayoutParams();
ViewGroup.LayoutParams lp = getSurface().getLayoutParams(); if (mVideoWidth * mVideoHeight == 0) {
mCameraContainerWidth = mSurfaceView.getLayoutParams().width; mSurfaceView.getLayoutParams().height = newHeight;