当前位置: 首页>>代码示例>>Java>>正文


Java SurfaceHolder.setFixedSize方法代码示例

本文整理汇总了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);
}
 
开发者ID:LiuJunb,项目名称:Android-LSS,代码行数:33,代码来源:StreamingActivity.java

示例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]);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:40,代码来源:HardwareScalerActivity.java

示例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();
}
 
开发者ID:anthorlop,项目名称:AJCPlayer,代码行数:15,代码来源:VideoPlayerActivity.java

示例4: surfaceChanged

import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
		int height) {
	holder.setFixedSize(width, height);
}
 
开发者ID:lbbniu,项目名称:CCDownload,代码行数:6,代码来源:ADMediaPlayActivity.java


注:本文中的android.view.SurfaceHolder.setFixedSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。