ImageView dentro de un ScrollView

I am working on a android project. I n that I have to deal with ScrollViews to scroll image. But when I am using ImageView dentro ScrollView image given to me is not fit in UI layout. So I am thinking I convert a ScrollView a ImageView. Is there any procedure in android. Plz help me.

preguntado el 02 de febrero de 12 a las 10:02

6 Respuestas

I found a nice solution, in your ImageView parameters, just add -


Respondido 19 Abr '13, 00:04

Prueba esto:

<?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android=""
        android:layout_height="fill_parent" >

            android:layout_height="wrap_content" >




Espero que esto ayude.

Respondido 02 Feb 12, 15:02

If you want to fit your imageview inside your emulator screen then why to use scrollview. You can scale your imageview inside your emulator screen like this

 LinearLayout linLayout = new LinearLayout(this);

        // load the origial BitMap (500 x 500 px)
        Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),

        int width = bitmapOrg.width();
        int height = bitmapOrg.height();
        int newWidth = 200;
        int newHeight = 200;

        // calculate the scale - in this case = 0.4f
        float scaleWidth = ((float) newWidth) / width;
        float scaleHeight = ((float) newHeight) / height;

        // createa matrix for the manipulation
        Matrix matrix = new Matrix();
        // resize the bit map
        matrix.postScale(scaleWidth, scaleHeight);
        // rotate the Bitmap

        // recreate the new Bitmap
        Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0,
                          width, height, matrix, true);

        // make a Drawable from Bitmap to allow to set the BitMap
        // to the ImageView, ImageButton or what ever
        BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);

        ImageView imageView = new ImageView(this);

        // set the Drawable on the ImageView

        // center the Image

        // add ImageView to the Layout
                new LinearLayout.LayoutParams(
                      LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT

        // set LinearLayout as ContentView

Espero eso ayude

Respondido 02 Feb 12, 15:02

thanks for reply. but i am working on project it is requirement to use scroll view because firtehr it is going to be in use - user1184851

so plz tell me convenient way. - user1184851

hello I think you can solve your problem like this






scroll view work within a layout.

Respondido 02 Feb 12, 14:02

I use the same above but my image resolution is going beyound the screen of screen.but i have to make that fully fit to screen of i try to ise android:background property.and in .java file i try to convert a scroll view to image view. if is there any method plz tell me.thanks in advance - user1184851





Esto funcionará para ti

Respondido 02 Feb 12, 14:02

based on ur previous comment dont set image in xml use setbackgroundresource in class file - Donald

I find a very easy solution, all you need to do is add


to your imageview in layout xml file.

Respondido 09 Abr '13, 08:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.