当xml里设置match_parent时,这句代码( int pixel = bitmap.getPixel(x, y);)在某些手机上会报错(x must be <= bitmap.getWidth())。
可在构造函数里强制:
int widthAndHeight = ViewGroup.LayoutParams.WRAP_CONTENT;
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(widthAndHeight, widthAndHeight);
setLayoutParams(params);
当xml里设置match_parent时,这句代码( int pixel = bitmap.getPixel(x, y);)在某些手机上会报错(x must be <= bitmap.getWidth())。
可在构造函数里强制:
int widthAndHeight = ViewGroup.LayoutParams.WRAP_CONTENT;
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(widthAndHeight, widthAndHeight);
setLayoutParams(params);