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

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

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

TextureView.getLayoutParams介绍

暂无

代码示例

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

  1. @Override
  2. public void updateAspectRatio(int width, int height) {
  3. if (mWidth * height < mHeight * width) {
  4. mTextureView.getLayoutParams().width = mWidth;
  5. mTextureView.getLayoutParams().height = mWidth * height / width;
  6. } else {
  7. mTextureView.getLayoutParams().width = mHeight * width / height;
  8. mTextureView.getLayoutParams().height = mHeight;
  9. }
  10. relayout();
  11. }

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

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

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

  1. private void updateWindowParams() {
  2. float scale = mWindowScale * mLiveScale;
  3. scale = Math.min(scale, (float)mDefaultDisplayMetrics.widthPixels / mWidth);
  4. scale = Math.min(scale, (float)mDefaultDisplayMetrics.heightPixels / mHeight);
  5. scale = Math.max(MIN_SCALE, Math.min(MAX_SCALE, scale));
  6. float offsetScale = (scale / mWindowScale - 1.0f) * 0.5f;
  7. int width = (int)(mWidth * scale);
  8. int height = (int)(mHeight * scale);
  9. int x = (int)(mWindowX + mLiveTranslationX - width * offsetScale);
  10. int y = (int)(mWindowY + mLiveTranslationY - height * offsetScale);
  11. x = Math.max(0, Math.min(x, mDefaultDisplayMetrics.widthPixels - width));
  12. y = Math.max(0, Math.min(y, mDefaultDisplayMetrics.heightPixels - height));
  13. if (DEBUG) {
  14. Log.d(TAG, "updateWindowParams: scale=" + scale
  15. + ", offsetScale=" + offsetScale
  16. + ", x=" + x + ", y=" + y
  17. + ", width=" + width + ", height=" + height);
  18. }
  19. mTextureView.setScaleX(scale);
  20. mTextureView.setScaleY(scale);
  21. mTextureView.setTranslationX(
  22. (mWidth - mTextureView.getLayoutParams().width) * scale / 2);
  23. mTextureView.setTranslationY(
  24. (mHeight - mTextureView.getLayoutParams().height) * scale / 2);
  25. mWindowParams.x = x;
  26. mWindowParams.y = y;
  27. mWindowParams.width = width;
  28. mWindowParams.height = height;
  29. }

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

  1. @Override protected void bindData(MyHolder holder, int position, Entity item) {
  2. if (!item.isVideo) {
  3. Glide.with(getContext()).load(item.url).into(((ImgHolder) holder).img);
  4. } else {
  5. mUrl = item.url;
  6. VideoHolder helper = (VideoHolder) holder;
  7. mPb = helper.pb;
  8. if (mPlayer == null) {
  9. mPb.setVisibility(View.VISIBLE);
  10. }
  11. helper.video.setVisibility(View.VISIBLE);
  12. ViewGroup.LayoutParams lp = helper.video.getLayoutParams();
  13. lp.height = 600;
  14. helper.video.setLayoutParams(lp);
  15. helper.video.setSurfaceTextureListener(this);
  16. }
  17. }

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

  1. @Override
  2. public void onGlobalLayout() {
  3. textureView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
  4. //设置控件大小
  5. RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) textureView.getLayoutParams();
  6. if (videoFormat.width > videoFormat.height) {
  7. layoutParams.height = textureView.getWidth() * videoFormat.height / videoFormat.width;
  8. } else {
  9. layoutParams.width = textureView.getHeight() * videoFormat.width / videoFormat.height;
  10. }
  11. textureView.setLayoutParams(layoutParams);
  12. //开始解码
  13. mp4Edior.stop();
  14. new Thread(new Runnable() {
  15. @Override
  16. public void run() {
  17. mp4Edior.start();
  18. textureView.setSurfaceTextureListener(AdjustActivity.this);
  19. mp4Edior.setLoop(true);
  20. mp4Edior.decodePrepare(videoPath);
  21. mSize = mp4Edior.getSize();
  22. mTransformation.setScale(mSize, mPreSize, MatrixUtils.TYPE_CENTERINSIDE);
  23. mp4Edior.setTransformation(mTransformation);
  24. mp4Edior.excuate();
  25. }
  26. }).start();
  27. }
  28. });

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

  1. mTextureView.setPivotX(0);
  2. mTextureView.setPivotY(0);
  3. mTextureView.getLayoutParams().width = mWidth;
  4. mTextureView.getLayoutParams().height = mHeight;
  5. mTextureView.setOpaque(false);
  6. mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);

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

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

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

  1. mPreviewView.getLayoutParams();

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

  1. /**
  2. * Adjust the size of the player so it fits on the screen.
  3. */
  4. private void scalePlayer() {
  5. int videoWidth = mediaPlayer.getVideoWidth();
  6. int videoHeight = mediaPlayer.getVideoHeight();
  7. float videoProportion = (float) videoWidth / (float) videoHeight;
  8. float screenProportion = (float) getWidth() / (float) getHeight();
  9. ViewGroup.LayoutParams lp = textureView.getLayoutParams();
  10. if (videoProportion > screenProportion) {
  11. lp.width = getWidth();
  12. lp.height = (int) ((float) getWidth() / videoProportion);
  13. } else {
  14. lp.width = (int) (videoProportion * (float) getHeight());
  15. lp.height = getHeight();
  16. }
  17. textureView.setLayoutParams(lp);
  18. }

相关文章