我想要什么:用两个位图创建图像,在第一个位图下放置第二个位图。
此时我使用此代码
public static Bitmap combineImages(Bitmap background, Bitmap foreground, float disFromTheTopPercent) {
int width = background.getWidth(), height = background.getHeight();
Bitmap cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cs);
background = Bitmap.createScaledBitmap(background, width, height, true);
comboImage.drawBitmap(background, 0, 0, null);
int top = (int) (disFromTheTopPercent * height);
int left = 0;
comboImage.drawBitmap(foreground, left, top, null);
return cs;
}
糟糕的是,它实际上与我 smartfon 中的身高、体重和 dpi 相关联。
当我使用具有 5 英寸屏幕和 6 英寸屏幕的 smartfone 时,它是不同的,无论不同的屏幕,这看起来都必须相同。
感谢帮助!