我正在研究Android游戏,并且出现了一些问题,我想在位图对象上填充颜色,但我不能尝试bitmap.setPixel但我的图像是PNG格式(如圆形或不锐化,用透明色包围)和android不能getHeight()或getWidth(),即
ImageView i = new ImageView(mContext); Bitmap bMap = BitmapFactory.decodeResource(this.mContext.getResources(), mImageIds[position]);Run Code Online (Sandbox Code Playgroud)// for(int i1 = 0; i1 < bMap.getHeight();i1++) // for(int j = 0; j < bMap.getWidth(); j ++) // bMap.setPixel(i1, j, Color.RED); //can not set
i.setImageBitmap(bMap); i.setLayoutParams(new Gallery.LayoutParams(150, 100)); i.setScaleType(ImageView.ScaleType.FIT_XY); i.setBackgroundResource(mGalleryItemBackground); i.setBackgroundColor(Color.TRANSPARENT);