书法字典:https://www.shufadict.com

onCreateView中加载大位图

我的一个Fragment中,加载了一个1024*1024的图片,非常卡。解决办法

1. 将图片改为512*512

2. 异步加载。

final SmartImageView mizige = (SmartImageView)view.findViewById(R.id.mizige);
        // Set the image asynchronous, this avoid the UI being no response.
        new AsyncTask<String, Void, Bitmap>() {
            @Override
            protected Bitmap doInBackground(String... paras) {
                return BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.linmo_mizige);
            }

            @Override
            protected void onPostExecute(Bitmap bitmap) {
                mizige.setImageBitmap(bitmap);
            }
        }.execute();

 

==

posted on 2015-08-08 08:57  翰墨小生  阅读(808)  评论(0编辑  收藏  举报

导航

书法字典:https://www.shufadict.com