开发一个九宫格抽奖系统 Android版
发布时间
阅读量:
阅读量
【
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mRectSize = Math.min(w, h)/3;//计算矩形的宽度与高度
mRects.clear();//当组件尺寸发生变化时,清除原有数据
initRect();//重新生成矩形信息
}
/**
- 初始化矩形数据
*/
private void initRect() {
//初始化前三块矩形区域
for(int x = 0;x<3;x++){
float left = x * mRectSize;
float top = 0;
float right = (x + 1) * mRectSize;
float bottom = mRectSize;
RectF rectF = new RectF(left,top,right,bottom);
mRects.add(rectF);
}
//初始化第四个矩形区域
mRects.add(new RectF(getWidth()-mRectSize,mRectSize,getWidth(),mRectSize * 2));
//初始化第五至第七个矩形区域
for(int
全部评论 (0)
还没有任何评论哟~
