Android:没有使用UIL和TouchImageView显示ImageView

Android:没有使用UIL和TouchImageView显示ImageView,第1张

概述我正在尝试使用UniversalImageLoader从URL实现加载图像,并使用TouchImageViewMikeOrtiz进行缩放.但是在尝试查看图像时,会显示黑屏.我已检查过网址是否正确.我是否在那里看到TextView…我究竟做错了什么?ImagePagerActivity.javapublicvoidonCreate(BundlesavedInstance

我正在尝试使用Universal Image Loader从URL实现加载图像,并使用touchImageVIEw Mike Ortiz进行缩放.但是在尝试查看图像时,会显示黑屏.我已检查过网址是否正确.我是否在那里看到TextVIEw …

我究竟做错了什么?

ImagePagerActivity.java

public voID onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    this.requestwindowFeature(Window.FEATURE_NO_Title);    setContentVIEw(R.layout.activity_fullscreen_vIEw);    Bundle bundle = getIntent().getExtras();    assert bundle != null;    String[] imageUrls = bundle.getStringArray("urls");    int pagerposition = bundle.getInt("pos", 0);    tipo = bundle.getString("tipo");    monumento = bundle.getString("monumento");    num = bundle.getInt("num");    for(int i = 0; i < imageUrls.length; i++) {        // URLS with data        Toast.makeText(this, "URL = " + imageUrls[i], 0).show();    }    if (savedInstanceState != null) {        pagerposition = savedInstanceState.getInt(STATE_position);    }    options = new displayImageOptions.Builder()        .showImageForEmptyUri(R.drawable.imagen)        .showImageOnFail(R.drawable.imagen)        .resetVIEwBeforeLoading(true)        .cacheOndisc(true)        .imageScaleType(ImageScaleType.EXACTLY)        .bitmapConfig(Bitmap.Config.RGB_565)        .consIDerExifParams(true)        .displayer(new FadeInBitmapdisplayer(300))        .build();    pager = (ExtendedVIEwPager) findVIEwByID(R.ID.pager);    pager.setAdapter(new ImagePagerAdapter(imageUrls));    pager.setCurrentItem(pagerposition);}@OverrIDepublic voID onSaveInstanceState(Bundle outState) {    outState.putInt(STATE_position, pager.getCurrentItem());}private class ImagePagerAdapter extends PagerAdapter {    private String[] images;    private LayoutInflater inflater;    ImagePagerAdapter(String[] images) {        this.images = images;        inflater = getLayoutInflater();    }    @OverrIDe    public voID destroyItem(VIEwGroup container, int position, Object object) {        container.removeVIEw((VIEw) object);    }    @OverrIDe    public int getCount() {        return images.length;    }    @OverrIDe    public Object instantiateItem(VIEwGroup vIEw, int position) {        final VIEw imageLayout = inflater.inflate(R.layout.ampliar_imagen, vIEw, false);        assert imageLayout != null;        imageVIEw = (touchImageVIEw) imageLayout.findVIEwByID(R.ID.imagenFullScreen);        infoImagen = (linearLayout)imageLayout.findVIEwByID(R.ID.textoInfoImagen);        info = (TextVIEw) imageLayout.findVIEwByID(R.ID.textoInfoImagenDesc);        cargarInfo(position, images);        androID.graphics.PorterDuff.Mode.MulTIPLY);        imageVIEw.setonClickListener(new VIEw.OnClickListener() {            @OverrIDe            public voID onClick(VIEw v) {                linearLayout infoImagen = (linearLayout)imageLayout.findVIEwByID(R.ID.textoInfoImagen);                if(infoImagen.getVisibility() == VIEw.GONE) {                    infoImagen.setVisibility(VIEw.VISIBLE);                } else {                    infoImagen.setVisibility(VIEw.GONE);                }            }        });        imageLoader.displayImage(images[position], imageVIEw, options, new SimpleImageLoadingListener() {            @OverrIDe            public voID onl oadingStarted(String imageUri, VIEw vIEw) {                spinner.setVisibility(VIEw.VISIBLE);            }            @OverrIDe            public voID onl oadingFailed(String imageUri, VIEw vIEw, FailReason failReason) {                spinner.setVisibility(VIEw.GONE);            }            @OverrIDe            public voID onl oadingComplete(String imageUri, VIEw vIEw, Bitmap loadedImage) {                spinner.setVisibility(VIEw.GONE);            }        });        vIEw.addVIEw(imageLayout, 0);        return imageLayout;    }    @OverrIDe    public boolean isVIEwFromObject(VIEw vIEw, Object object) {        return vIEw.equals(object);    }    @OverrIDe    public voID restoreState(Parcelable state, ClassLoader loader) {    }    @OverrIDe    public Parcelable saveState() {        return null;    }}private voID cargarInfo(int position, String[] images) {    if(tipo.equals("fotos")) {        info.setText((position + 1) + " de " + images.length +                "\n" + InfoImagenes.devolverInfoFotos(monumento, position, num, ImagePagerActivity.this));    }    else if(tipo.equals("planos")) {        info.setText((position + 1) + " de " + images.length +                "\n" + InfoImagenes.devolverInfoPlanos(position, num, ImagePagerActivity.this));    }}

activity_full_screen.xml

<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="match_parent"androID:layout_height="match_parent"androID:orIEntation="vertical" > <imagenes.ExtendedVIEwPager     androID:ID="@+ID/pager"    androID:layout_wIDth="fill_parent"    androID:layout_height="fill_parent" /></linearLayout>

ampliar_imagen.xml

<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="match_parent"androID:layout_height="match_parent"androID:background="@color/negro" ><FrameLayout    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent" >    <imagenes.touchImageVIEw        androID:ID="@+ID/imagenFullScreen"        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent"        androID:layout_gravity="center"        androID:adjustVIEwBounds="true" />    <Progressbar        androID:ID="@+ID/cargandoFoto"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_gravity="center"        androID:visibility="gone" /></FrameLayout><linearLayout    androID:ID="@+ID/textoInfoImagen"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:layout_alignParentBottom="true"    androID:background="@color/gristransparente"    androID:orIEntation="horizontal"    androID:visibility="visible" >    <TextVIEw        androID:ID="@+ID/textoInfoImagenDesc"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_weight="1"        androID:gravity="center_horizontal"        androID:paddingBottom="3dp"        androID:paddingtop="3dp"        androID:textcolor="@color/blanco"        androID:textSize="13sp" /></linearLayout></relativeLayout>

编辑

如果我通过ImageVIEw更改touchImageVIEw,则会显示图像

解决方法:

我也遇到了这个问题,我发现它与Progressbar的可见性有关,并且可以使用以下代码来解决它.

>在onLoadingStarted()中,添加vIEw.setVisibility(VIEw.GONE)
>在onLoadingComplete()中,添加vIEw.setVisibility(VIEw.VISIBLE)

码:

imageLoader.displayImage(imageUri.toString(),                      mPictureVIEw,                     options,                     new SimpleImageLoadingListener(){@OverrIDepublic voID onl oadingStarted(String imageUri, VIEw vIEw) {    spinner.setVisibility(VIEw.VISIBLE);    vIEw.setVisibility(VIEw.GONE);}@OverrIDepublic voID onl oadingFailed(String imageUri, VIEw vIEw, FailReason failReason) {    spinner.setVisibility(VIEw.GONE);}@OverrIDepublic voID onl oadingComplete(String imageUri, VIEw vIEw, Bitmap loadedImage){    spinner.setVisibility(VIEw.GONE);    vIEw.setVisibility(VIEw.VISIBLE);}});
总结

以上是内存溢出为你收集整理的Android:没有使用UIL和TouchImageView显示ImageView全部内容,希望文章能够帮你解决Android:没有使用UIL和TouchImageView显示ImageView所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1097945.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存