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

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

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

SurfaceView.getLayoutParams介绍

暂无

代码示例

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

int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
float screenProportion = (float) screenWidth / (float) screenHeight;
android.view.ViewGroup.LayoutParams lp = surfaceViewFrame.getLayoutParams();

代码示例来源: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: 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: 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: ghondar/react-native-vlc-player

holder.setFixedSize(finalWidth, finalHeight);
ViewGroup.LayoutParams lp = mSurface.getLayoutParams();
lp.width = finalWidth;
lp.height = finalHeight;

代码示例来源:origin: xugaoxiang/VLCAndroidMultiWindow

LayoutParams lp = mSurface.getLayoutParams();
lp.width = vidW;
lp.height = vidH;

代码示例来源:origin: xugaoxiang/VLCAndroidMultiWindow

LayoutParams lp = mSurface.getLayoutParams();
lp.width = vidW;
lp.height = vidH;

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

int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
float screenProportion = (float) screenWidth / (float) screenHeight;
android.view.ViewGroup.LayoutParams lp = surfaceViewFrame.getLayoutParams();

代码示例来源: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: stackoverflow.com

.getLayoutParams();

代码示例来源:origin: lizhangqu/Camera

RelativeLayout.LayoutParams surfaceviewParams = (RelativeLayout.LayoutParams) mSurfaceView.getLayoutParams();
surfaceviewParams.width = heightPixels * 4 / 3;
surfaceviewParams.height = heightPixels;

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

screenHeight = size.y;
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mSurfaceView.getLayoutParams();

代码示例来源:origin: amahi/android

ViewGroup.LayoutParams lp = getSurface().getLayoutParams();
if (mVideoWidth * mVideoHeight == 0) {

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

mCameraContainerWidth = mSurfaceView.getLayoutParams().width;
  mSurfaceView.getLayoutParams().height = newHeight;

相关文章