有趣的是找到如何将图像添加到列表中的容器(气球)行? 完全覆盖该地区(气球)(Android)
__________ |imageVeiw | /imageView | \imageView | |__________|
更新:
我找到了解决。 结果图: http://i57.tinypic.com/dndok0.jpg
public void makeMaskImage(ImageView mImageView, int mContent)
{
Bitmap original = BitmapFactory.decodeResource(getResources(), mContent);
Bitmap mask = BitmapFactory.decodeResource(getResources(),R.drawable.mask);
int h = original.getHeight()/(original.getWidth()/mask.getWidth());
original = Bitmap.createScaledBitmap(original, mask.getWidth(), h, false);
Bitmap result = Bitmap.createBitmap(mask.getWidth(), mask.getHeight(), Config.ARGB_8888);
Canvas mCanvas = new Canvas(result);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
mCanvas.drawBitmap(original, 0, 0, null);
mCanvas.drawBitmap(mask, 0, 0, paint);
paint.setXfermode(null);
mImageView.setImageBitmap(result);
mImageView.setScaleType(ScaleType.CENTER);
//mImageView.setBackgroundResource(R.drawable.frame);
}
答案 0 :(得分:0)
使用此方法将气球图像转换为9patch图像(http://draw9patch.com/).while在图像区域的四边转换为9patch设置相等的空间。还可以下载并参考本教程(http://javapapers.com/android/android-chat-bubble/)以获得清晰的想法。 / p>