onCreateView中加載大位圖

個人一個Fragment中,加載了一個1024*1024的圖片,很是卡。解決辦法異步

1. 將圖片改成512*512async

2. 異步加載。ide

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

 

==this

相關文章
相關標籤/搜索