标签:parent file http plain create string androi exception ali
<ImageView android:layout_width="match_parent" android:layout_height="300dp" android:id="@+id/id_loc" android:scaleType="fitXY" />
<uk.co.senab.photoview.PhotoView android:layout_width="match_parent" android:layout_height="400dp" android:src="@mipmap/ic_launcher" android:id="@+id/id_myimg"/>
//本地加载方法一 // 设置图片 Drawable bitmap = getResources().getDrawable(R.mipmap.ic_launcher); loc.setImageDrawable(bitmap); // 连接在photoview中 PhotoViewAttacher mAttacher = new PhotoViewAttacher(loc); mAttacher.update();//更新
//本地方法加载二 PhotoViewAttacher mAttacher; mAttacher = new PhotoViewAttacher(loc); iv.setImageBitmap(bitmap); Glide.with(this).load(R.mipmap.ic_launcher).asBitmap().into(loc); mAttacher.update();
对于网络也是可以用ImageView和PhotoView两种
把ImageView或者PhotoView的对象名直接添加到display中就OK 了。
//加载网络图片 ImageLoader loader= ImageLoader.getInstance(); loader.init(ImageLoaderConfiguration.createDefault(ImageTest.this));//loader初始化 loader.displayImage("https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1529211252&di=1414331e22239ecb5730cbbd0f3793eb&src=http://pic154.nipic.com/file/20180114/26629113_090329120799_2.jpg",loc);//展示图片
下面我们可以看一下源码,其实他也是继承了ImageView
/** * Adds display image task to execution pool. Image will be set to ImageView when it‘s turn. <br/> * Default {@linkplain DisplayImageOptions display image options} from {@linkplain ImageLoaderConfiguration * configuration} will be used.<br /> * <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method call * * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png") * @param imageView {@link ImageView} which should display image * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn‘t called before * @throws IllegalArgumentException if passed <b>imageView</b> is null */ public void displayImage(String uri, ImageView imageView) { displayImage(uri, new ImageViewAware(imageView), null, null, null); }
完
标签:parent file http plain create string androi exception ali
原文地址:https://www.cnblogs.com/cmusketeer/p/9192687.html