日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android 仿微信群聊头像 合成图片

發布時間:2023/12/14 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 仿微信群聊头像 合成图片 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

android 仿微信群聊頭像 合成圖片,微信中可以顯示出群頭像為多個用戶的頭像網格,這里講方法已經封裝好,

如果有記得點贊哦!!

先看效果:

使用例子:

@Override public void onClick(View v) {PNUtils.runThread(new Runnable() {@Overridepublic void run() {Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.cx_facebook_icon);Bitmap bitmap1 = BitmapFactory.decodeResource(getResources(), R.mipmap.cx_google_icon);Bitmap bitmap3 = BitmapFactory.decodeResource(getResources(), R.mipmap.cx_twitter);Bitmap bitmap4 = BitmapFactory.decodeResource(getResources(), R.mipmap.cx_weixin_icon);List<Bitmap> bitmaps=new ArrayList<>();bitmaps.add(bitmap);bitmaps.add(bitmap1);bitmaps.add(bitmap3);bitmaps.add(bitmap4);final Bitmap bitmap2=PNUtils.createHeaderBitmap(bitmaps, 300, 300, 2, "#000000");runOnUiThread(new Runnable() {@Overridepublic void run() {imageView.setImageBitmap(bitmap2);}});}}); }public static Bitmap createHeaderBitmap(List<Bitmap> bitmaps,int maxWidth,int maxHeight, int columnNums, String backgroundColor) {if (bitmaps.size()==0)return null;int itemWidth=maxWidth/columnNums;int itemHeight=maxHeight/columnNums;int rows=-1;Bitmap bitmap2 = Bitmap.createBitmap(maxWidth, maxHeight, Bitmap.Config.ARGB_8888);Canvas canvas=new Canvas(bitmap2);canvas.drawColor(Color.parseColor(backgroundColor));for (int i=0; i<bitmaps.size(); i++) {int column=i%columnNums;if (column==0)rows++;canvas.drawBitmap(resizeBitmap(bitmaps.get(i), itemWidth), column*itemWidth, rows*itemHeight, null);}return bitmap2; }/*** 重新修改圖片大小*/ public static Bitmap resizeBitmap(Bitmap bitmap, int newWidth) {float scaleWidth = ((float) newWidth) / bitmap.getWidth();Matrix matrix = new Matrix();matrix.postScale(scaleWidth, scaleWidth);Bitmap bmpScale = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);return bmpScale; }

總結

以上是生活随笔為你收集整理的android 仿微信群聊头像 合成图片的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。