Image framing

Asked

Viewed 74 times

1

I’m trying to put a 704x480 image in an Imageview, but it’s floating with spaces above and below.

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>

inserir a descrição da imagem aqui

  • What do you want to happen? Do you want me to take the whole screen?

  • 3

    Try using the property android:adjustViewBounds="true".

1 answer

1


You can play a little with the android:scaleType of Imageview.

By default it comes as fitCenter, so you see the image in the center, and the top and bottom black. Try for example set the value of the property with fitXY, you will see that the image will adjust to the size of your Imageview, independent of the screen size of your device.

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


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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.