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

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

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

TextureView.setScaleX介绍

暂无

代码示例

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

float scale = (width * 1.0f) / (height * 1.0f);
videoView.setRotation(rotation);
videoView.setScaleX(scale);

代码示例来源: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;
}

相关文章