1,加在網絡圖片
x.image().bind(imageView, url, imageOptions);112,加載assets文件夾下的圖片
x.image().bind(imageView, "assets://test.gif", imageOptions);113,加載文件夾下的圖片
x.image().bind(imageView, new File("/sdcard/test.gif").toURI().toString(), imageOptions); x.image().bind(imageView, "/sdcard/test.gif", imageOptions); x.image().bind(imageView, "file:///sdcard/test.gif", imageOptions); x.image().bind(imageView, "file:/sdcard/test.gif", imageOptions);123412344,需要對加載的圖片作進一步處理的話
x.image().bind(imageView, url, imageOptions, new Callback.CommonCallback<Drawable>() {...});x.image().loadDrawable(url, imageOptions, new Callback.CommonCallback<Drawable>() {...});x.image().loadFile(url, imageOptions, new Callback.CommonCallback<File>() {...});1231235,imageOptions是對圖片的參數進行進一步的設置
imageOptions = new ImageOptions.Builder() .setSize(DensityUtil.dip2px(120), DensityUtil.dip2px(120)) .setRadius(DensityUtil.dip2px(5)) // 如果ImageView的大小不是定義為wrap_content, 不要crop. .setCrop(true) // 加載中或錯誤圖片的ScaleType //.setPlaceholderScaleType(ImageView.ScaleType.MATRIX) .setImageScaleType(ImageView.ScaleType.CENTER_CROP) //設置加載過程中的圖片 .setLoadingDrawableId(R.drawable.ic_launcher) //設置加載失敗后的圖片 .setFailureDrawableId(R.drawable.ic_launcher) //設置使用緩存 .setUseMemCache(true) //設置支持gif .setIgnoreGif(false) //設置顯示圓形圖片 .setCircular(false) .setSquare(true) .build();
新聞熱點
疑難解答