本文整理了Java中android.view.SurfaceView.onSizeChanged()
方法的一些代码示例,展示了SurfaceView.onSizeChanged()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SurfaceView.onSizeChanged()
方法的具体详情如下:
包路径:android.view.SurfaceView
类名称:SurfaceView
方法名:onSizeChanged
暂无
代码示例来源:origin: codeestX/ENViews
@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();
}
代码示例来源:origin: OpenCVBlueprints/OpenCVBlueprints
@Override
public void onSizeChanged(int w,int h,int oldw,int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
sizeWidth = w;
sizeHeight = h;
}
代码示例来源:origin: lessthanoptimal/BoofAndroidDemo
@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;
}
代码示例来源:origin: InnoFang/Android-Code-Demos
@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;
}
代码示例来源:origin: wuyr/CatchPiggy
@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));
}
代码示例来源:origin: google-developer-training/android-advanced
/**
* 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();
}
代码示例来源:origin: yanbober/MagicFloatView
@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);
}
}
代码示例来源:origin: luozhanming/LuckyBoard
@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);
}
内容来源于网络,如有侵权,请联系作者删除!