Skip to content

int pixel = bitmap.getPixel(x, y);报错 #2

@ghost

Description

当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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions