3

我从内部存储或互联网获得位图。当我尝试在 ImageView 中显示它时,它适用于不同的模拟器版本,但不适用于我的 Galaxy S I9000。位图根本不显示。

protected void onPostExecute (Bitmap bmp) {
    progressBar.setVisibility(View.INVISIBLE);
    if (bmp != null) {
        imageView.setImageBitmap(bmp);
        imageView.setVisibility(View.VISIBLE);
    }
}
4

2 回答 2

3

这很可能是 openGL 不接受大于 2400x2400 的纹理的潜在问题。它不会导致崩溃,但会因不在 ImageView 中显示位图而失败。

您应该始终确保位图在两个维度上都小于 2400,如果它更大,则在将其设置到您的视图之前调整它的大小。

于 2013-01-09T20:45:30.633 回答
0

我使用这种方法来帮助我显示图像

public static Drawable ToDrawable(Resources r, byte[] encodedString) 
    {
        if (encodedString == null)
            return null;

        Bitmap bmp = BitmapFactory.decodeByteArray(encodedString, 0, encodedString.length);
        Drawable drawable = new BitmapDrawable(r, bmp);
        // bmp.recycle();
        return drawable;

    }
于 2013-02-26T10:45:56.900 回答