Search code examples
androidimageimageviewimage-scaling

Is it possible to display original image in android without fit to device views?


I have an Image of size 1000px*1200px and i want it to be displayed without being scaled!.

I have searched in stackover flow and google i am not getting good one.

I want full image without scaled, I have tried like this

Step1:-

<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/image"
                />

Step2:-

I have tried with scaleType also add a scaleType to your ImageView

 <ImageView
    android:scaleType="center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/image" />

But this is also not working,

In sclate type i have tried with all possible properties (matrix,fitXY like this).

is there any possibility there for doing to dispaly original image in android?

Plz help me on this


Solution

  • After many trails i have find a solution for above question.

    Here is the code:

    MainActivity:-

    public class MainActivity extends ActionBarActivity {
    
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            setContentView(R.layout.activity_main);
    
            ImageView imageView = (ImageView) this.findViewById(R.id.imageview);
       }
    }
    

    activity_main.xml:-

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView android:id="@+id/ScrollView02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scrollbars="none"
        xmlns:android="http://schemas.android.com/apk/res/android">
        <HorizontalScrollView android:id="@+id/HorizontalScrollView01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <ImageView android:id="@+id/imageview"
                android:src="@drawable/desert"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:adjustViewBounds="true">
            </ImageView>
        </HorizontalScrollView>
    </ScrollView>
    

    This is working perfectly for my requirement.

    Hope this helps to others.