Android Bitmap Drawable 常用摘要
2024-08-25 08:42:47
1、缩放
public Bitmap scalingBitmap(Bitmap bitmap, int newW, int newH) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
float sx = (float) newW / w;
float sy = (float) newH / h;
Matrix matrix = new Matrix();
matrix.postScale(sx, sy); // 长和宽放大缩小的比例
return Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
}
2、代码修改shape颜色
GradientDrawable myGrad = (GradientDrawable) view.getBackground();
myGrad.setColor(Color.parseColor("#4bd1c9"));
最新文章
- 【jquery】字符ascii码转换函数
- HDU5785 Interesting(Manacher + 延迟标记)
- Linux_导出函数
- hdu 4712 Hamming Distance 随机
- 【狼】unity3d iTween插件的学习
- 【转】java中equal与==的区别 其中有个缓冲区,需要注意
- MyBatis学习日记(三):戏说MyBatis配置文件
- PC机Win10声音问题两例处理办法
- java程序中默认浮点形值常量是什么类型的?如何区分不同类型的浮点型整数值常量?
- 复制数组之System.arraycopy()的使用
- Xamarin Essentials教程使用加速度传感器Accelerometer
- vue改变了数据却没有自动刷新
- C#语言与变量、数据类型
- 【转】Oracle virtual column(虚拟列)
- Activex控件的IObjectSafety接口问题
- [Android 开发教程(1)]-- Saving Data in SQL Databases
- SVN安装后bin中没有svn.exe,TortoiseSVN安装后bin目录中没有svn.exe;
- bzoj1834: [ZJOI2010]network 网络扩容 费用流
- 云数据库Redis版256M双机热备款
- video事件