Android_(自定义view_3)
来源:互联网 发布:php正则验证身份证 编辑:程序博客网 时间:2024/05/20 10:12
笔记由个人学习整理
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int width, height; //设置大小 int contentWidth = 200; int contentHeight = 200; width = getMeasurement(widthMeasureSpec, contentWidth); height = getMeasurement(heightMeasureSpec, contentHeight); //必须调用此方法 setMeasuredDimension(width, height); }
/* * 辅助设置大小的方法 */ private int getMeasurement(int measureSpec, int contentSize) { int specSize = MeasureSpec.getSize(measureSpec); switch (MeasureSpec.getMode(measureSpec)) { case MeasureSpec.AT_MOST: return Math.min(specSize, contentSize); case MeasureSpec.UNSPECIFIED: return contentSize; case MeasureSpec.EXACTLY: return specSize; default: return 0; } }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { if (w != oldw || h != oldh) { //如果大小有变,要重置中心点以及半径 mCenter.x = w / 2; mCenter.y = h / 2; mRadius = Math.min(mCenter.x, mCenter.y); } }
0 0
- Android_(自定义view_3)
- android自定义View_3——Optimizing the View
- Android_自定义控件
- Android_自定义控件样式
- android_自定义notification
- android_自定义弹出框
- android_自定义Loading框
- Android_自定义控件
- Android_自定义标签换行
- Android_(自定义view_2)
- Android_自定义View
- Android_自定义ViewPager指示器
- android_自定义折叠View
- Android_自定义View拖拽重绘
- Android_自定义标签ViewLayout
- Android_自定义删除View
- Android_自定义倒计时View
- Android_自定义控件_HorizontalListView
- Swift的String类型转换如何实现?
- 推荐C++ Primer 第五版
- HITOJ Prime Land 1069 (求质因子) 好题
- 一步一步学写makefile
- R中的SQL包--sqldf
- Android_(自定义view_3)
- Confluence5.8.10安装、破解、设置
- vs2005 + DriverStudio3.2 修改方法
- vs2003一查找就卡死了
- 【可持久化线段树】poj 2104 静态区间第k大
- js unicode编码与解码
- DAMAGE:After normal block(#****)错误
- Java高并发笔记
- 选课