Adjust Image/Bitmap to Imageview or adjust Imageview to Image/Bitmap

Asked

Viewed 2,462 times

3

I’m trying to create a menu screen something like this:

Layout que fiz usando Adobe XD CC

To make this cut diagonally, I made this image to stay on top of the background: inserir a descrição da imagem aqui

However, in Android Studio, I can not resize the image to occupy the space needed on the screen, I’m using the Constraint Layout and when trying to enlarge the image, even with an image of high resolution she gets like this:

inserir a descrição da imagem aqui

It does not increase right, I have tried to touch various settings like: Scaletype, Adjustviewbounds, cropToPadding, I’m all day behind that and so far nothing

Follow her XML code:

    <ImageView
    android:id="@+id/imageView"
    android:layout_width="616dp"
    android:layout_height="449dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:srcCompat="@mipmap/ic_diag" />

1 answer

1

When defining absolute values for android:layout_width and android:layout_height Imageview will be presented with these dimensions.

  • If you want the Imageview fits the dimensions of layout that it contains should use match_parent and, eventually, android:adjustViewBounds="true".

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:srcCompat="@mipmap/ic_diag" />
    
  • If you want the image fits the size of the Imageview may need to use one of the android:scaleType.
    The type to be used will depend on the size and format of the image and the final result you want to obtain (with or without deformation, image cut or not).

  • Hello, Ramaral, thanks for your help! But you still haven’t solved the problem. See how it looks: https://image.prntscr.com/image/yfsTAtjLRHGWvMaJgsSQZw.png

  • See the considerations added to the answer.

Browser other questions tagged

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