本文整理汇总了Java中android.view.TextureView.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java TextureView.getHeight方法的具体用法?Java TextureView.getHeight怎么用?Java TextureView.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.TextureView
的用法示例。
在下文中一共展示了TextureView.getHeight方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureTransform
import android.view.TextureView; //导入方法依赖的package包/类
private void configureTransform(TextureView textureView) {
if (null == textureView || null == mPreviewSize || null == mActivity) {
return;
}
int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
Matrix matrix = new Matrix();
RectF viewRect = new RectF(0, 0, textureView.getWidth(), textureView.getHeight());
RectF bufferRect = new RectF(0, 0, mPreviewSize.y, mPreviewSize.x);
float centerX = viewRect.centerX();
float centerY = viewRect.centerY();
if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
float scale = Math.max(
(float) textureView.getHeight() / mPreviewSize.y,
(float) textureView.getWidth() / mPreviewSize.x);
matrix.postScale(scale, scale, centerX, centerY);
}
matrix.postRotate(-90 * rotation, centerX, centerY);
textureView.setTransform(matrix);
}
示例2: scale
import android.view.TextureView; //导入方法依赖的package包/类
/**
* Performs the requested scaling on the <code>view</code>'s matrix
*
* @param view The TextureView to alter the matrix to achieve the requested scale type
* @param scaleType The type of scaling to use for the specified view
* @return True if the scale was applied
*/
public boolean scale(@NonNull TextureView view, @NonNull ScaleType scaleType) {
if (!ready()) {
requestedScaleType = scaleType;
requestedModificationView = new WeakReference<>(view);
return false;
}
if (view.getHeight() == 0 || view.getWidth() == 0) {
Log.d(TAG, "Unable to apply scale with a view size of (" + view.getWidth() + ", " + view.getHeight() + ")");
return false;
}
currentScaleType = scaleType;
switch (scaleType) {
case CENTER:
applyCenter(view);
break;
case CENTER_CROP:
applyCenterCrop(view);
break;
case CENTER_INSIDE:
applyCenterInside(view);
break;
case FIT_CENTER:
applyFitCenter(view);
break;
case NONE:
setScale(view, 1, 1);
break;
}
return true;
}
示例3: applyCenterCrop
import android.view.TextureView; //导入方法依赖的package包/类
/**
* Applies the {@link ScaleType#CENTER_CROP} to the specified matrix. This will
* make sure the smallest side fits the parent container, cropping the other
*
* @param view The view to apply the transformation to
*/
protected void applyCenterCrop(@NonNull TextureView view) {
float xScale = (float)view.getWidth() / intrinsicVideoSize.x;
float yScale = (float)view.getHeight() / intrinsicVideoSize.y;
float scale = Math.max(xScale, yScale);
xScale = scale / xScale;
yScale = scale / yScale;
setScale(view, xScale, yScale);
}
示例4: applyCenterInside
import android.view.TextureView; //导入方法依赖的package包/类
/**
* Applies the {@link ScaleType#CENTER_INSIDE} to the specified matrix. This will
* only perform scaling if the video is too large to fit completely in the <code>view</code>
* in which case it will be scaled to fit
*
* @param view The view to apply the transformation to
*/
protected void applyCenterInside(@NonNull TextureView view) {
if(intrinsicVideoSize.x <= view.getWidth() && intrinsicVideoSize.y <= view.getHeight()) {
applyCenter(view);
} else {
applyFitCenter(view);
}
}
示例5: applyFitCenter
import android.view.TextureView; //导入方法依赖的package包/类
/**
* Applies the {@link ScaleType#FIT_CENTER} to the specified matrix. This will
* scale the video so that the largest side will always match the <code>view</code>
*
* @param view The view to apply the transformation to
*/
protected void applyFitCenter(@NonNull TextureView view) {
float xScale = (float)view.getWidth() / intrinsicVideoSize.x;
float yScale = (float)view.getHeight() / intrinsicVideoSize.y;
float scale = Math.min(xScale, yScale);
xScale = scale / xScale;
yScale = scale / yScale;
setScale(view, xScale, yScale);
}
示例6: setScale
import android.view.TextureView; //导入方法依赖的package包/类
/**
* Applies the specified scale modification to the view
*
* @param view The view to scale
* @param xScale The scale to apply to the x axis
* @param yScale The scale to apply to the y axis
*/
protected void setScale(@NonNull TextureView view, float xScale, float yScale) {
//If the width and height have been swapped, we need to re-calculate the scales based on the swapped sizes
boolean currentWidthHeightSwapped = ((currentRotation / QUARTER_ROTATION) % 2) == 1;
if (currentWidthHeightSwapped){
float scaleTemp = xScale;
xScale = yScale * view.getHeight() / view.getWidth();
yScale = scaleTemp * view.getWidth() / view.getHeight();
}
view.setScaleX(xScale);
view.setScaleY(yScale);
}
示例7: applyCenter
import android.view.TextureView; //导入方法依赖的package包/类
/**
* Applies the {@link ScaleType#CENTER} to the specified matrix. This will
* perform no scaling as this just indicates that the video should be centered
* in the View
*
* @param view The view to apply the transformation to
*/
protected void applyCenter(@NonNull TextureView view) {
float xScale = (float) intrinsicVideoSize.x / view.getWidth();
float yScale = (float) intrinsicVideoSize.y / view.getHeight();
setScale(view, xScale, yScale);
}