當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。