Image framing

1

I'm trying to put a 704x480 image in an ImageView, but it floats with spaces up and down.

Ex:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/image"
        android:src="@drawable/demo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

    
asked by anonymous 30.06.2016 / 06:49

1 answer

1

You can play around with android:scaleType of Imageview .

By default it comes as fitCenter , so you see the image in the center, and the top and bottom black. For example, if you set the property value to fitXY , you'll see that the image will adjust to the size of your Imageview , regardless of the screen size of your device.

In this link has a complete list with each type of scale and an example of each.

You can also use the hint suggested by @Bruno Romualdo in the comments and use android:adjustViewBounds="true" , in this case it will be Imageview that will fit your image.

    
30.06.2016 / 18:55