skip to Main Content

I have a question, how do you resize a background image in android studio to match the whole layout for example:
I have a drawable that is landscape by default, but my layout is horizontal, I want to decrease the width and increase the height of thag photo to match thr layout, how do I do that??

4

Answers


  1. You need to scale your image, add this property and change the fitCenter by the one that corresponds to your criteria android:scaleType="fitCenter".

    Login or Signup to reply.
  2. Hope this helps. I think you have to add :

    android:scaleType="fitXY"
    android:adjustViewBounds="true"
    

    But still, check out the link I attached, so you can have a better understanding.

    Login or Signup to reply.
  3. There are android scale types which you can refer CENTER, CENTER_CROP, CENTER_INSIDE, FIT_CENTER, FIT_END, FIT_START, FIT_XY and MATRIX. which can be used as per your requirement. But as you mentioned you can try android:scaleType="center_crop" which crops the image a bit but covers the whole screen

    Login or Signup to reply.
  4. This Should do the trick

    android:scaleType="fitXY"
    android:adjustViewBounds="true"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search