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


Java Display.getSize方法代码示例

本文整理汇总了Java中android.view.Display.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java Display.getSize方法的具体用法?Java Display.getSize怎么用?Java Display.getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.Display的用法示例。


在下文中一共展示了Display.getSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onInitXul

import android.view.Display; //导入方法依赖的package包/类
public void onInitXul() {
	{
		// initialize global xul page size
		WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
		Display display = wm.getDefaultDisplay();
		Point displaySize = new Point();
		display.getSize(displaySize);
		int pageWidth = displaySize.x;
		int pageHeight = displaySize.y;

		// fix some device with incompatible resolution
		if (pageHeight > 665 && pageHeight < 720) {
			pageHeight = 720;
		} else if (pageHeight > 1000 && pageHeight < 1080) {
			pageHeight = 1080;
		}

		XulManager.setPageSize(pageWidth, pageHeight);
	}
	onInitXulWorker();
	onLoadXul();
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:23,代码来源:XulApplication.java

示例2: checkDisplaySize

import android.view.Display; //导入方法依赖的package包/类
public static void checkDisplaySize() {
    try {
        Configuration configuration = applicationContext.getResources()
                .getConfiguration();
        usingHardwareInput = configuration.keyboard != Configuration.KEYBOARD_NOKEYS
                && configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
        WindowManager manager = (WindowManager) applicationContext
                .getSystemService(Context.WINDOW_SERVICE);
        if (manager != null) {
            Display display = manager.getDefaultDisplay();
            if (display != null) {
                display.getMetrics(displayMetrics);
                display.getSize(displaySize);
                Log.d("tmessages", "display size = " + displaySize.x + " " + displaySize.y + " "
                        + displayMetrics.xdpi + "x" + displayMetrics.ydpi);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:chengzichen,项目名称:KrGallery,代码行数:22,代码来源:AndroidUtilities.java

示例3: b

import android.view.Display; //导入方法依赖的package包/类
@SuppressLint({"NewApi"})
public static Point b() {
    Display defaultDisplay = ((WindowManager) hn.a().c().getSystemService("window")).getDefaultDisplay();
    Point point = new Point();
    if (VERSION.SDK_INT >= 17) {
        defaultDisplay.getRealSize(point);
    } else if (VERSION.SDK_INT >= 14) {
        try {
            Method method = Display.class.getMethod("getRawHeight", new Class[0]);
            point.x = ((Integer) Display.class.getMethod("getRawWidth", new Class[0]).invoke(defaultDisplay, new Object[0])).intValue();
            point.y = ((Integer) method.invoke(defaultDisplay, new Object[0])).intValue();
        } catch (Throwable th) {
            defaultDisplay.getSize(point);
        }
    } else if (VERSION.SDK_INT >= 13) {
        defaultDisplay.getSize(point);
    } else {
        point.x = defaultDisplay.getWidth();
        point.y = defaultDisplay.getHeight();
    }
    return point;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:jl.java

示例4: setup

import android.view.Display; //导入方法依赖的package包/类
@Override
public void setup(Activity activity) {
    mRootView = activity.getWindow().getDecorView();
    /*
    mRootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            Util.log("onGlobalLayout");
        }
    });
    */

    // Get DisplayHeight
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    mDisplayHeight = point.y;

    Util.log("setup mDisplayHeight:%s point:%s", mDisplayHeight, point.toString());
}
 
开发者ID:qiujuer,项目名称:AirPanel,代码行数:21,代码来源:Helper.java

示例5: onCreate

import android.view.Display; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splashscreen_main);

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);

    //marshmallow check permission permissions
    boolean hasPermission = (ContextCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
    if (!hasPermission) {
        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                REQUEST_WRITE_STORAGE);
    } else {
        validateFilesAndDownload();
    }

}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:22,代码来源:MainActivity.java

示例6: onCreate

import android.view.Display; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.first_photo);
    Display display = getWindowManager().getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            Intent passenger = new Intent(FarmerActivity.this,IntroductionPage.class);
            startActivity(passenger);
        }
    }, 2500);

}
 
开发者ID:JamesNikolaidis,项目名称:Thesis_Farmers_Helper,代码行数:17,代码来源:FarmerActivity.java

示例7: initFromCameraParameters

import android.view.Display; //导入方法依赖的package包/类
/**
 * Reads, one time, values from the camera that are needed by the app.
 */
@SuppressLint("NewApi")
void initFromCameraParameters(Camera camera) {
	Camera.Parameters parameters = camera.getParameters();
	WindowManager manager = (WindowManager) context
			.getSystemService(Context.WINDOW_SERVICE);
	Display display = manager.getDefaultDisplay();
	Point theScreenResolution = new Point();
	display.getSize(theScreenResolution);
	screenResolution = theScreenResolution;
	Log.i(TAG, "Screen resolution: " + screenResolution);
	// 解决竖屏拉伸
	Point screenResolutionForCamera = new Point();
	screenResolutionForCamera.x = screenResolution.x;
	screenResolutionForCamera.y = screenResolution.y;
	if (screenResolution.x < screenResolution.y) {
		screenResolutionForCamera.x = screenResolution.y;
		screenResolutionForCamera.y = screenResolution.x;
	}
	// cameraResolution = getCameraResolution(parameters, screenResolution);
	cameraResolution = findBestPreviewSizeValue(parameters,
			screenResolutionForCamera);
	Log.i(TAG, "Camera resolution: " + cameraResolution);
}
 
开发者ID:dufangyu1990,项目名称:LeCatApp,代码行数:27,代码来源:CameraConfigurationManager.java

示例8: getScreenHeight

import android.view.Display; //导入方法依赖的package包/类
public static int getScreenHeight(Context c) {
    if (screenHeight == 0) {
        WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        screenHeight = size.y;
    }

    return screenHeight;
}
 
开发者ID:hoanganhtuan95ptit,项目名称:MeteorView,代码行数:12,代码来源:Utils.java

示例9: drawResizedBitmap

import android.view.Display; //导入方法依赖的package包/类
private void drawResizedBitmap(final Bitmap src, final Bitmap dst) {

        Display getOrient = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        int orientation = Configuration.ORIENTATION_UNDEFINED;
        Point point = new Point();
        getOrient.getSize(point);
        int screen_width = point.x;
        int screen_height = point.y;
        Log.d(TAG, String.format("screen size (%d,%d)", screen_width, screen_height));
        if (screen_width < screen_height) {
            orientation = Configuration.ORIENTATION_PORTRAIT;
            mScreenRotation = -90;
        } else {
            orientation = Configuration.ORIENTATION_LANDSCAPE;
            mScreenRotation = 0;
        }

        Assert.assertEquals(dst.getWidth(), dst.getHeight());
        final float minDim = Math.min(src.getWidth(), src.getHeight());

        final Matrix matrix = new Matrix();

        // We only want the center square out of the original rectangle.
        final float translateX = -Math.max(0, (src.getWidth() - minDim) / 2);
        final float translateY = -Math.max(0, (src.getHeight() - minDim) / 2);
        matrix.preTranslate(translateX, translateY);

        final float scaleFactor = dst.getHeight() / minDim;
        matrix.postScale(scaleFactor, scaleFactor);

        // Rotate around the center if necessary.
        if (mScreenRotation != 0) {
            matrix.postTranslate(-dst.getWidth() / 2.0f, -dst.getHeight() / 2.0f);
            matrix.postRotate(mScreenRotation);
            matrix.postTranslate(dst.getWidth() / 2.0f, dst.getHeight() / 2.0f);
        }

        final Canvas canvas = new Canvas(dst);
        canvas.drawBitmap(src, matrix, null);
    }
 
开发者ID:gicheonkang,项目名称:fast_face_android,代码行数:41,代码来源:OnGetImageListener.java

示例10: getScreenWidth

import android.view.Display; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private static int getScreenWidth(Context context) {
  WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  Display display = wm.getDefaultDisplay();
  Point size = new Point();
  display.getSize(size);
  return size.x;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:RecyclerAdapter.java

示例11: doInBackground

import android.view.Display; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@TargetApi(13)
@Override
protected Void doInBackground(String... s) {
    String qrData = s[0];
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point outSize = new Point();
    int x, y, qrCodeDimension;
    /* lame, got to use both the new and old APIs here */
    if (Build.VERSION.SDK_INT >= 13) {
        display.getSize(outSize);
        x = outSize.x;
        y = outSize.y;
    } else {
        x = display.getWidth();
        y = display.getHeight();
    }
    if (x < y) {
        qrCodeDimension = x;
    } else {
        qrCodeDimension = y;
    }
    Utils.debugLog(TAG, "generating QRCode Bitmap of " + qrCodeDimension + "x" + qrCodeDimension);
    QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(qrData, null,
            Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), qrCodeDimension);

    try {
        qrBitmap = qrCodeEncoder.encodeAsBitmap();
    } catch (WriterException e) {
        Log.e(TAG, "Could not encode QR as bitmap", e);
    }
    return null;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:34,代码来源:QrGenAsyncTask.java

示例12: getScreenWidth

import android.view.Display; //导入方法依赖的package包/类
/**
 * Get width of device screen
 *
 * @param c context
 * @return screen width
 */
@SuppressLint("NewApi")
static Integer getScreenWidth(Context c) {
    int width = 0;
    WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    if (Build.VERSION.SDK_INT > 12) {
        Point size = new Point();
        display.getSize(size);
        width = size.x;
    } else {
        width = display.getWidth(); // deprecated
    }
    return width;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:PrefStore.java

示例13: getScreenHeight

import android.view.Display; //导入方法依赖的package包/类
/**
 * get the screen height in pixels
 * @param context
 * @return
 */
public static int getScreenHeight(Context context) {
    if (screenHeight == -1) {
        Display display = ((Activity)context).getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        screenHeight = size.y;
    }
    return screenHeight;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:WoWoUtil.java

示例14: getScreenWidth

import android.view.Display; //导入方法依赖的package包/类
public static int getScreenWidth(Context c) {
    if (screenWidth == 0) {
        WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        screenWidth = size.x;
    }

    return screenWidth;
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:12,代码来源:Utils.java

示例15: calculateLayoutSize

import android.view.Display; //导入方法依赖的package包/类
protected LinearLayout.LayoutParams calculateLayoutSize(){
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    return new LinearLayout.LayoutParams(size.x/numberOfItensPerPage, getLayoutParams().height);
}
 
开发者ID:lucas-asu,项目名称:carousel-picker-android,代码行数:8,代码来源:CarouselView.java


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