1

I want to set a background image in my app, which will fill all screen and scale if needed, so I set it in my main_layout.xml like that:

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:adjustViewBounds="true"
    android:id="@+id/imageView"
    android:src="@drawable/bg_iphone_6_plus" />

and it looks like this api >= 16

not very good, I need this picture to adjust in width too, actually.

ok, so this works in most cases and with all API's higher 16, but when I run my app on api lower 16 ( minTargetSdk=14 ), I see this:

enter image description here

I have no idea why it shows like that, I have already tried this tutorial, and replaced ImageView with com.inthecheesefactory.thecheeselibrary.widget.AdjustableImageView

but it didn't change anything at all

animekun
  • 1,789
  • 4
  • 28
  • 45

2 Answers2

1

Try with replacing android:src property with android:background in your ImageView layout. I think that will solve your issue. If it is still causing the issue then please let me know.

Abhishek
  • 920
  • 13
  • 23
1

If your background image is only this gray picture with gradient in the middle, then move the drawable to android:background to parent container. You don't need additional ImageView for that.

But, if you want to set bitmap as background and keep ratio of this image on different devices and orientations, you should use ImageView and its android:scaleType with e.g. "centerCrop" (which usually is the best choice for backgrounds).

paulina_glab
  • 2,467
  • 2
  • 16
  • 25