congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
SurfaceView.setLayoutParams
Code IndexAdd Tabnine to your IDE (free)

How to use
setLayoutParams
method
in
android.view.SurfaceView

Best Java code snippets using android.view.SurfaceView.setLayoutParams (Showing top 20 results out of 315)

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;
}
android.viewSurfaceViewsetLayoutParams

Popular methods of SurfaceView

  • getHolder
  • <init>
  • onMeasure
  • onInitializeAccessibilityEvent
  • onInitializeAccessibilityNodeInfo
  • onKeyDown
  • setOnTouchListener
  • onDetachedFromWindow
  • setVisibility
  • getLayoutParams
  • onAttachedToWindow
  • onTouchEvent
  • onAttachedToWindow,
  • onTouchEvent,
  • onSizeChanged,
  • setOnClickListener,
  • getHeight,
  • getWidth,
  • setKeepScreenOn,
  • onLayout,
  • setZOrderOnTop

Popular in Java

  • Making http post requests using okhttp
  • getApplicationContext (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • putExtra (Intent)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • JLabel (javax.swing)
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now