Though usually not visible to the application, Drawables may take a variety of forms: 尽管通常情况下对于应用是不可见的,Drawables 可以采取很多形式: Bitmap: the simplest Drawable, a PNG or JPEG image. Bitmap: 简单化的Drawable, PNG 或JPEG图像. Nine Patch: an extension to the PNG format allows it to specify information about how to stretch it and place things inside of it. Shape: contains simple drawing commands instead of a raw bitmap, allowing it to resize better in some cases. Layers: a compound drawable, which draws multiple underlying drawables on top of each other. States: a compound drawable that selects one of a set of drawables based on its state. Levels: a compound drawable that selects one of a set of drawables based on its level. Scale: a compound drawable with a single child drawable, whose overall size is modified based on the current level.
| 对比项 | 显示清晰度 | 支持透明色 | 支持色相色差调整 | 支持像素操作 |
|---|---|---|---|---|
| Bitmap | 相同 | 是 | 是 | 是 |
| Drawable | 相同 | 是 | 否 | 否 |
//setImageResource() public void setImageResource (int resId)//占用UI thread; // setImageBitmap() ImageView iv; String fileName = "/data/data/com.test/aa.png"; Bitmap bm = BitmapFactory.decodeFile(fileName); iv.setImageBitmap(bm); //占用内存 // setImageBitmap() Bitmap image = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); imageView.setImageBitmap(image); // Bitmap转换成Drawable Bitmap image = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); BitmapDrawable bitmapDrawable = new BitmapDrawable(image); imageView.setImageDrawable(bitmapDrawable); // 结论:Bitmap是Drawable . Drawable不一定是Bitmap
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有