Reputation: 17081
I am trying to set a background image to my ViewPager (android.support.v4.view.ViewPager)
. It can be done via android:background="@drawable/bg"
- however, it stretches the image.
For ImageView's
I can set scaleType="centerCrop"
to prevent this but this doesn't seem to work for PagerView
. How can I prevent the background from stretching? I've tried adding an ImageView
as a subview of my ViewPager
but that doesn't seem to work either.
Thanks in advance!
Upvotes: 1
Views: 794
Reputation: 18863
Sorry, there are no 'centerCrop' option for background drawable. How I do it is set your use FrameLayout having the back contain the ImageView using centerCrop, then the front(top) will be your content with transparent background.
Upvotes: 1