gpt4 book ai didi

com.zx.zxutils.util.ZXScreenUtil.getScreenHeight()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:36:39 26 4
gpt4 key购买 nike

本文整理了Java中com.zx.zxutils.util.ZXScreenUtil.getScreenHeight()方法的一些代码示例,展示了ZXScreenUtil.getScreenHeight()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZXScreenUtil.getScreenHeight()方法的具体详情如下:
包路径:com.zx.zxutils.util.ZXScreenUtil
类名称:ZXScreenUtil
方法名:getScreenHeight

ZXScreenUtil.getScreenHeight介绍

[英]获取屏幕的高度(单位:px)
[中]获取屏幕的高度(单位:px)

代码示例

代码示例来源:origin: StannyBing/ZXUtils

private static Rect calculateTapArea(float x, float y, float coefficient, Context context) {
  float focusAreaSize = 300;
  int areaSize = Float.valueOf(focusAreaSize * coefficient).intValue();
  int centerX = (int) (x / ZXScreenUtil.getScreenWidth() * 2000 - 1000);
  int centerY = (int) (y / ZXScreenUtil.getScreenHeight() * 2000 - 1000);
  int left = clamp(centerX - areaSize / 2, -1000, 1000);
  int top = clamp(centerY - areaSize / 2, -1000, 1000);
  RectF rectF = new RectF(left, top, left + areaSize, top + areaSize);
  return new Rect(Math.round(rectF.left), Math.round(rectF.top), Math.round(rectF.right), Math.round(rectF
      .bottom));
}

代码示例来源:origin: StannyBing/ZXUtils

/**
 * 获取当前屏幕截图,包含状态栏
 *
 * @param activity
 * @return
 */
public static Bitmap getScreenShot(Activity activity) {
  View view = activity.getWindow().getDecorView();
  view.setDrawingCacheEnabled(true);
  view.buildDrawingCache();
  Bitmap bmp = view.getDrawingCache();
  int width = getScreenWidth();
  int height = getScreenHeight();
  Bitmap bp = null;
  bp = Bitmap.createBitmap(bmp, 0, 0, width, height);
  view.destroyDrawingCache();
  return bp;
}

代码示例来源:origin: StannyBing/ZXUtils

/**
 * 获取当前屏幕截图,不包含状态栏
 *
 * @param activity
 * @return
 */
public static Bitmap getScreenShotWithoutStatusBar(Activity activity) {
  View view = activity.getWindow().getDecorView();
  view.setDrawingCacheEnabled(true);
  view.buildDrawingCache();
  Bitmap bmp = view.getDrawingCache();
  Rect frame = new Rect();
  activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
  int statusBarHeight = frame.top;
  int width = getScreenWidth();
  int height = getScreenHeight();
  Bitmap bp = null;
  bp = Bitmap.createBitmap(bmp, 0, statusBarHeight, width, height
      - statusBarHeight);
  view.destroyDrawingCache();
  return bp;
}

代码示例来源:origin: StannyBing/ZXUtils

break;
case 1://获取屏幕的高度
  btnbarView.printInfo("屏幕高度:" + ZXScreenUtil.getScreenHeight());
  break;
case 2://设置屏幕为横屏

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com