本文整理汇总了Java中android.view.SurfaceHolder.setFixedSize方法的典型用法代码示例。如果您正苦于以下问题:Java SurfaceHolder.setFixedSize方法的具体用法?Java SurfaceHolder.setFixedSize怎么用?Java SurfaceHolder.setFixedSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.SurfaceHolder
的用法示例。
在下文中一共展示了SurfaceHolder.setFixedSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fitPreviewToParentByResolution
import android.view.SurfaceHolder; //导入方法依赖的package包/类
private void fitPreviewToParentByResolution(SurfaceHolder holder, int width, int height) {
// Adjust the size of SurfaceView dynamically
int screenHeight = getWindow().getDecorView().getRootView().getHeight();
int screenWidth = getWindow().getDecorView().getRootView().getWidth();
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { // If
// portrait,
// we
// should
// swap
// width
// and
// height
width = width ^ height;
height = width ^ height;
width = width ^ height;
}
// Fit height
int adjustedVideoHeight = screenHeight;
int adjustedVideoWidth = screenWidth;
if (width * screenHeight > height * screenWidth) { // means width/height
// >
// screenWidth/screenHeight
// Fit width
adjustedVideoHeight = height * screenWidth / width;
adjustedVideoWidth = screenWidth;
} else {
// Fit height
adjustedVideoHeight = screenHeight;
adjustedVideoWidth = width * screenHeight / height;
}
holder.setFixedSize(adjustedVideoWidth, adjustedVideoHeight);
}
示例2: onRadioButtonClicked
import android.view.SurfaceHolder; //导入方法依赖的package包/类
/**
* onClick handler for radio buttons.
*/
public void onRadioButtonClicked(View view) {
int newSize;
RadioButton rb = (RadioButton) view;
if (!rb.isChecked()) {
Log.d(TAG, "Got click on non-checked radio button");
return;
}
switch (rb.getId()) {
case R.id.surfaceSizeTiny_radio:
newSize = SURFACE_SIZE_TINY;
break;
case R.id.surfaceSizeSmall_radio:
newSize = SURFACE_SIZE_SMALL;
break;
case R.id.surfaceSizeMedium_radio:
newSize = SURFACE_SIZE_MEDIUM;
break;
case R.id.surfaceSizeFull_radio:
newSize = SURFACE_SIZE_FULL;
break;
default:
throw new RuntimeException("Click from unknown id " + rb.getId());
}
mSelectedSize = newSize;
int[] wh = mWindowWidthHeight[newSize];
// Update the Surface size. This causes a "surface changed" event, but does not
// destroy and re-create the Surface.
SurfaceView sv = (SurfaceView) findViewById(R.id.hardwareScaler_surfaceView);
SurfaceHolder sh = sv.getHolder();
Log.d(TAG, "setting size to " + wh[0] + "x" + wh[1]);
sh.setFixedSize(wh[0], wh[1]);
}
示例3: onResume
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
mChromeCast.resume();
SurfaceHolder holder = mSurfaceView.getHolder();
DisplayMetrics metrics = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(metrics);
holder.setFixedSize(metrics.widthPixels, (int) ((float) metrics.widthPixels / (float) 16 / (float) 9));
holder.addCallback(this);
videoPlayer.onViewSizeChanged();
}
示例4: surfaceChanged
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
holder.setFixedSize(width, height);
}