Reputation: 509
I have a viewpager into which I'm inflating an imageview; I used the android:scaleType="fitXY" but there's still some black around the image why and how can I stretch it so that it be as if it was a background? thanks.
layout of the viewpager:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Introduction_Activity"
>
<android.support.v4.view.ViewPager
android:id="@+id/imgs_viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
image view layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:id="@+id/img_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/desc_intro"
android:scaleType="fitXY"
android:adjustViewBounds="true"
/>
</LinearLayout>
Upvotes: 0
Views: 429
Reputation: 14173
you have to remove padding from relative layout, they are eating space from the ViewPager
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
Upvotes: 0
Reputation:
This is not clear here may be you use a padding on your view pager or a view flipper due to that the margin left and right occurs if you do this thing you cant stretch it to the maximum width.. so try to remove padding and works with the weight to set the viewpager size
Upvotes: 1