@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); mWidth = w; mHeight = h; mCenterX = w / 2; mCenterY = h / 2; mBaseLength = w / 10; mBgBaseLength = w / 8; for (int i = 0; i < 4 ;i++) { mCurrentRippleX[i] = - 2 * mBgBaseLength; } mPath.reset(); mPath.moveTo(0, mCenterY + 2 * mBaseLength); mPath.lineTo(0, mCenterY); mPath.lineTo(mBaseLength / 4, mCenterY - mBaseLength); mPath.lineTo(mBaseLength / 4, mCenterY - 1.5f * mBaseLength); mPath.lineTo(mBaseLength * 3 / 4, mCenterY - 1.5f * mBaseLength); mPath.lineTo(mBaseLength * 3 / 4, mCenterY - mBaseLength); mPath.lineTo(mBaseLength, mCenterY); mPath.lineTo(mBaseLength, mCenterY + 2 * mBaseLength); mPath.close(); }
@Override public void onSizeChanged(int w,int h,int oldw,int oldh) { super.onSizeChanged(w, h, oldw, oldh); sizeWidth = w; sizeHeight = h; }
@Override protected void onSizeChanged (int w, int h, int oldw, int oldh) { super.onSizeChanged(w,h,oldw,oldh); // the smallest side in the view area smallest = Math.min(w,h); this.surfaceWidth = w; this.surfaceHeight = h; }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); mHeight = h; mWidth = w; mDialRadius = Math.min(mWidth, mHeight) / 2 - 100; mLen = 20F; mSecondsPointerLen = mDialRadius - 70; mMinutesPointerLen = mSecondsPointerLen - 50; mHourPointerLen = mMinutesPointerLen - 40; }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); mCenterX = w / 2; mCenterY = h / 2; //圆的最大半径取手机屏幕对角线的一半 mMaxRadius = (int) Math.sqrt(Math.pow(mCenterX, 2) + Math.pow(mCenterY, 2)); }
/** * We cannot get the correct dimensions of views in onCreate because * they have not been inflated yet. This method is called every time the * size of a view changes, including the first time after it has been * inflated. * * @param w Current width of view. * @param h Current height of view. * @param oldw Previous width of view. * @param oldh Previous height of view. */ @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); mViewWidth = w; mViewHeight = h; mFlashlightCone = new FlashlightCone(mViewWidth, mViewHeight); // Set font size proportional to view size. mPaint.setTextSize(mViewHeight / 5); mBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.android); setUpBitmap(); }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); //TODO default position. mTouchPoint.x = getMeasuredWidth() / 2; mTouchPoint.y = getMeasuredHeight() / 2; mRandomParticles = new ArrayList<>(); for (int index=0 ;index<250; index++) { RandomParticle particle = new RandomParticle(getMeasuredWidth(), getMeasuredHeight()); mRandomParticles.add(particle); } }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); mButtonPath = new Path(); mButtonPath.addCircle(getWidth() / 2, getHeight() / 2, (float) (blockSize * 0.75 / 2 - Util.dp2px(getContext(), 5)), Path.Direction.CCW); mButtonRegion = new Region(); Region clip = new Region(0, 0, w, h); mButtonRegion.setPath(mButtonPath, clip); }