标签:
public void paint() { if (item.laying_mode != 1)//平铺或者充满 { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { Looper.prepare(); try { theBitmap = Glide. with(ctxt). load(item.src). asBitmap(). into(fenbianlv[0], fenbianlv[1]).//这里fenbianlv这个数组的元素是屏幕的宽度和高度 get(); } catch (final ExecutionException e) { Log.e(TAG, e.getMessage()); } catch (final InterruptedException e) { Log.e(TAG, e.getMessage()); } return null; } @Override protected void onPostExecute(Void dummy) { if (null != theBitmap) { // The full bitmap should be available here BitmapDrawable bd = new BitmapDrawable(theBitmap); if (item.laying_mode == 0)//充满(默认值,缩放到图片全部充满屏幕 { } else if (item.laying_mode == 2)//平铺(从左上开始,一个一个的平铺) { bd.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT); } rl.setBackground(bd); } } }.execute(); } else//1:居中(图片按照原始大小,放到屏幕中间) { Glide.with(ctxt).load(item.src).asBitmap().into(iv); } }
标签:
原文地址:http://www.cnblogs.com/kunyashaw/p/5110708.html