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

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

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

TextureView.getLayoutParams介绍

暂无

代码示例

代码示例来源:origin: googlesamples/android-MediaRouter

@Override
public void updateAspectRatio(int width, int height) {
  if (mWidth * height < mHeight * width) {
    mTextureView.getLayoutParams().width = mWidth;
    mTextureView.getLayoutParams().height = mWidth * height / width;
  } else {
    mTextureView.getLayoutParams().width = mHeight * width / height;
    mTextureView.getLayoutParams().height = mHeight;
  }
  relayout();
}

代码示例来源:origin: Affectiva/affdexme-android

void displayVideo(TextureView videoView) {
  textureView = videoView;
  ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(textureView.getLayoutParams());
  // set the video to the same height and width of the actual bitmap inside the imageview
  int[] imageAttr = ImageHelper.getBitmapPositionInsideImageView(imageView);
  params.width = imageAttr[2]; //width
  params.height = imageAttr[3]; //height
  textureView.setLayoutParams(params);
  videoHolder.addView(textureView);
  textureView.setVisibility(VISIBLE);
  videoOverlay.setVisibility(VISIBLE);
}

代码示例来源:origin: googlesamples/android-MediaRouter

private void updateWindowParams() {
  float scale = mWindowScale * mLiveScale;
  scale = Math.min(scale, (float)mDefaultDisplayMetrics.widthPixels / mWidth);
  scale = Math.min(scale, (float)mDefaultDisplayMetrics.heightPixels / mHeight);
  scale = Math.max(MIN_SCALE, Math.min(MAX_SCALE, scale));
  float offsetScale = (scale / mWindowScale - 1.0f) * 0.5f;
  int width = (int)(mWidth * scale);
  int height = (int)(mHeight * scale);
  int x = (int)(mWindowX + mLiveTranslationX - width * offsetScale);
  int y = (int)(mWindowY + mLiveTranslationY - height * offsetScale);
  x = Math.max(0, Math.min(x, mDefaultDisplayMetrics.widthPixels - width));
  y = Math.max(0, Math.min(y, mDefaultDisplayMetrics.heightPixels - height));
  if (DEBUG) {
    Log.d(TAG, "updateWindowParams: scale=" + scale
        + ", offsetScale=" + offsetScale
        + ", x=" + x + ", y=" + y
        + ", width=" + width + ", height=" + height);
  }
  mTextureView.setScaleX(scale);
  mTextureView.setScaleY(scale);
  mTextureView.setTranslationX(
      (mWidth - mTextureView.getLayoutParams().width) * scale / 2);
  mTextureView.setTranslationY(
      (mHeight - mTextureView.getLayoutParams().height) * scale / 2);
  mWindowParams.x = x;
  mWindowParams.y = y;
  mWindowParams.width = width;
  mWindowParams.height = height;
}

代码示例来源:origin: AriaLyy/BlogDemo

@Override protected void bindData(MyHolder holder, int position, Entity item) {
 if (!item.isVideo) {
  Glide.with(getContext()).load(item.url).into(((ImgHolder) holder).img);
 } else {
  mUrl = item.url;
  VideoHolder helper = (VideoHolder) holder;
  mPb = helper.pb;
  if (mPlayer == null) {
   mPb.setVisibility(View.VISIBLE);
  }
  helper.video.setVisibility(View.VISIBLE);
  ViewGroup.LayoutParams lp = helper.video.getLayoutParams();
  lp.height = 600;
  helper.video.setLayoutParams(lp);
  helper.video.setSurfaceTextureListener(this);
 }
}

代码示例来源:origin: yangjie10930/OpenGL4Android

@Override
  public void onGlobalLayout() {
    textureView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
    //设置控件大小
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) textureView.getLayoutParams();
    if (videoFormat.width > videoFormat.height) {
      layoutParams.height = textureView.getWidth() * videoFormat.height / videoFormat.width;
    } else {
      layoutParams.width = textureView.getHeight() * videoFormat.width / videoFormat.height;
    }
    textureView.setLayoutParams(layoutParams);
    //开始解码
    mp4Edior.stop();
    new Thread(new Runnable() {
      @Override
      public void run() {
        mp4Edior.start();
        textureView.setSurfaceTextureListener(AdjustActivity.this);
        mp4Edior.setLoop(true);
        mp4Edior.decodePrepare(videoPath);
        mSize = mp4Edior.getSize();
        mTransformation.setScale(mSize, mPreSize, MatrixUtils.TYPE_CENTERINSIDE);
        mp4Edior.setTransformation(mTransformation);
        mp4Edior.excuate();
      }
    }).start();
  }
});

代码示例来源:origin: googlesamples/android-MediaRouter

mTextureView.setPivotX(0);
mTextureView.setPivotY(0);
mTextureView.getLayoutParams().width = mWidth;
mTextureView.getLayoutParams().height = mHeight;
mTextureView.setOpaque(false);
mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);

代码示例来源:origin: fly-studio/douyin-downloader

RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams)textureView.getLayoutParams();
lp.width = viewRect.width;
lp.height = viewRect.height;

代码示例来源:origin: vbier/habpanelviewer

mPreviewView.getLayoutParams();

代码示例来源:origin: klinker24/Android-SimpleVideoView

/**
 * Adjust the size of the player so it fits on the screen.
 */
private void scalePlayer() {
  int videoWidth = mediaPlayer.getVideoWidth();
  int videoHeight = mediaPlayer.getVideoHeight();
  float videoProportion = (float) videoWidth / (float) videoHeight;
  float screenProportion = (float) getWidth() / (float) getHeight();
  ViewGroup.LayoutParams lp = textureView.getLayoutParams();
  if (videoProportion > screenProportion) {
    lp.width = getWidth();
    lp.height = (int) ((float) getWidth() / videoProportion);
  } else {
    lp.width = (int) (videoProportion * (float) getHeight());
    lp.height = getHeight();
  }
  textureView.setLayoutParams(lp);
}

相关文章