本文整理了Java中com.zx.zxutils.util.ZXScreenUtil.getScreenWidth()
方法的一些代码示例,展示了ZXScreenUtil.getScreenWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZXScreenUtil.getScreenWidth()
方法的具体详情如下:
包路径:com.zx.zxutils.util.ZXScreenUtil
类名称:ZXScreenUtil
方法名:getScreenWidth
[英]获取屏幕的宽度(单位:px)
[中]获取屏幕的宽度(单位:px)
代码示例来源:origin: StannyBing/ZXUtils
public FoucsView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.size = ZXScreenUtil.getScreenWidth() / 3;
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setColor(0xEE16AE16);
mPaint.setStrokeWidth(4);
mPaint.setStyle(Paint.Style.STROKE);
}
代码示例来源:origin: StannyBing/ZXUtils
/**
* 用于处理上下的view出现右边超出屏幕的问题
*
* @param locationx
* @return
*/
private int compareWithScreenWidthTopOrBottom(int locationx) {
if (locationx + getMeasuredWidth() > ZXScreenUtil.getScreenWidth()) {//超出屏幕外了(右边)
return ZXScreenUtil.getScreenWidth() - getMeasuredWidth();//此时刚好到屏幕右侧
} else {
return locationx < -20 ? -20 : locationx;
}
}
代码示例来源: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 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
/**
* 获取当前屏幕截图,包含状态栏
*
* @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
/**
* 用于处理左右的view出现左右超出屏幕的问题(重新定义popupwindow的宽度)
*
* @param locationx
* @param type
* @return
*/
private int compareWithScreenWidthLeftOrRight(int locationx, int type) {
if (type == 0) {//left
if (locationx < 0) {//左侧超出屏幕外了
setWidth(locationx + getMeasuredWidth());
return 0;
}
} else {//right
if (locationx + getMeasuredWidth() > ZXScreenUtil.getScreenWidth()) {//右侧超出屏幕外了
setWidth(ZXScreenUtil.getScreenWidth() - locationx);
}
}
return locationx;
}
代码示例来源:origin: StannyBing/ZXUtils
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent motionEvent) {
if (bgVisible) {
rv.requestDisallowInterceptTouchEvent(true);
} else if ((ZXScreenUtil.getScreenWidth() > touchedX + 150)
&& (motionEvent.getRawX() - touchedX < 0)) {
rv.requestDisallowInterceptTouchEvent(true);
} else {
rv.requestDisallowInterceptTouchEvent(false);
}
return handleTouchEvent(motionEvent);
}
代码示例来源:origin: StannyBing/ZXUtils
private void initData() {
layout_width = ZXScreenUtil.getScreenWidth();
//缩放梯度
zoomGradient = (int) (layout_width / 16f);
ZXLogUtil.logi("zoom = " + zoomGradient);
machine = new CameraMachine(getContext(), this, this);
}
代码示例来源:origin: StannyBing/ZXUtils
switch (position) {
case 0://获取屏幕的宽度
btnbarView.printInfo("屏幕宽度:" + ZXScreenUtil.getScreenWidth());
break;
case 1://获取屏幕的高度
内容来源于网络,如有侵权,请联系作者删除!