@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); // Logger.d(TAG, String.format("onSizeChanged, w: %s, h: %s, oldw: %s, oldh: %s", w, h, // oldw, oldh)); if (isFirst && w > 0 && h > 0) { isFirst = false; originWidth = w; originHeight = h; originRadius = Math.min(originWidth, originHeight) / 2; curRadius = originRadius; touchedPointRadius = originRadius; maxMoveLength = ABAppUtil.getDeviceHeight(context) / 6; refreshStartPoint(); ViewGroup.LayoutParams lp = this.getLayoutParams(); if (RelativeLayout.LayoutParams.class.isAssignableFrom(lp.getClass())) { originLp = (RelativeLayout.LayoutParams) lp; } newLp = new RelativeLayout.LayoutParams(lp.width, lp.height); } }
/** 修改layoutParams后,需要重新设置startPoint */ private void refreshStartPoint() { location = new int[2]; this.getLocationInWindow(location); // Logger.d(TAG, "location on screen: " + Arrays.toString(location)); // startPoint.set(location[0], location[1] + h); try { location[1] = location[1] - ABAppUtil.getTopBarHeight((Activity) context); } catch (Exception ex) { } startPoint.set(location[0], location[1] + getMeasuredHeight()); // Logger.d(TAG, "startPoint: " + startPoint); }