Search code examples
androidimageviewpicasso

Large Image Not Showing in ImageView using Picasso


This is my Image

I want to show ImageView with ScrollView

Code:

  Picasso.get().load(img_url2)
            .fit().centerInside()
            .into(imageView2);

XML:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#dddddd">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/img2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="vertical"/>

    </LinearLayout>
</ScrollView>

Solution

  • I spend some days to find solution. below I add entire necessary code

    In Manifest

     android:hardwareAccelerated="false"
    

    In XML file

    <ProgressBar
        android:id="@+id/progressBarId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" />
    
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#dddddd">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
    
            <com.jsibbold.zoomage.ZoomageView
                android:id="@+id/imageViewId"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:scrollbars="vertical"
                android:scaleType="matrix"
                app:zoomage_animateOnReset="true"
                app:zoomage_doubleTapToZoom="true"
                app:zoomage_maxScale="8"
                app:zoomage_zoomable="true" />
        </LinearLayout>
    </ScrollView>
    

    In Java Code

        progressBar.setVisibility(View.VISIBLE);
        Glide.with(getApplicationContext())
                .load(pdf_link)
                .listener(new RequestListener<Drawable>() {
                    @Override
                    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                        return false;
                    }
    
                    @Override
                    public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                        progressBar.setVisibility(View.GONE);
                        return false;
                    }
                })
                .into(imageView);
    

    In Dependency

    implementation 'com.jsibbold:zoomage:1.3.1'
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'