android 在Button 的onDraw中加上invalidate()会导致背景缩放失败
来源:互联网 发布:苍穹软件使用教程 编辑:程序博客网 时间:2024/05/19 06:18
android 在Button 的onDraw中加上invalidate()会导致背景缩放失败,如果需要不断刷新则需要手动设置背景大小
protected void onDraw(Canvas canvas){ super.onDraw(canvas); if(getBackground()!=null) { background=getBackground(); setBackground(null); } background.setBounds(0, 0, getWidth(), getHeight()); Bitmap bitmap= drawableToBitmap(background); Matrix matrix=new Matrix(); matrix.postScale(getWidth()*1.0f/background.getIntrinsicWidth(),getHeight()*1.0f/background.getIntrinsicHeight()); Bitmap scaledBitmap=Bitmap.createBitmap(bitmap, 0, 0, background.getIntrinsicWidth(), background.getIntrinsicHeight(),matrix,true); canvas.drawBitmap(scaledBitmap, 0, 0, paint); invalidate();}
0 0
- android 在Button 的onDraw中加上invalidate()会导致背景缩放失败
- 在业务类中忘记加上 @Component 导致的错误
- Android在配置文件中配置Button再不同情况下的的背景
- Invalidate()函数,WM_PAINT,OnDraw函数的关系
- Android中设置Button或者ImageButton的背景透明
- 【问题汇总】在C/C++中使用Android Log导致编译失败的问题
- 会导致人生失败的一些因素
- 关于CScrollView中SetScrollSizes导致的OnDraw的无限调用
- 关于Android调用invalidate()之后不能及时调用ondraw()的解决办法
- Android中给Button加上selector——点击按钮后变成不一样的图片
- Android中给Button加上selector——点击按钮后变成不一样的图片
- Android draw、onDraw、dispatchDraw、invalidate、computeScroll 一些简要说明
- Android draw、onDraw、dispatchDraw、invalidate、computeScroll 一些简要说明
- Android draw、onDraw、dispatchDraw、invalidate区别与联系
- MFC SDI程序中OnDraw,OnPait,OnEraseBkGnd,Invalidate,UpdateWindow
- onDraw() and invalidate()
- Android的selector,Button按钮背景选择器
- android的selector背景选择器(Button篇)
- 一篇浅显介绍逻辑回归的文章
- MySQL 触发器学习
- debug调试,注册表
- NoSQL开篇——为什么要使用NoSQL
- ajax处理返回的json格式数据
- android 在Button 的onDraw中加上invalidate()会导致背景缩放失败
- Tomcat日志系统详细配置
- Shell快捷键
- 7.php策略模式
- Linq DataTable的修改和查询
- openwrt升级功能介绍
- php操作redis常用方法代码例子
- 关系数据库还是NoSQL数据库
- IOS-TextField知多少