I am using Universal Image Loader v 1.9.1 . I am getting blank space at the start and end of image(horizontally).Cant figure out how to get imageview occupy full width of screen. could this be an issue with images?
MY code Snippets are:
ac_image_pager.xml
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="200dp"
/>
item_pager_image.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dp"
>
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="200dp"
android:adjustViewBounds="true"
android:contentDescription="@string/descr_image" />
<ProgressBar
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_gravity="center"
android:visibility="gone" />
</FrameLayout>
ImagePagerActivity.java
Following init configs for pageviewer
options = new DisplayImageOptions.Builder()
.showImageForEmptyUri(R.drawable.ic_empty)
.showImageOnFail(R.drawable.ic_error)
.resetViewBeforeLoading(true)
.cacheOnDisc(true)
.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
.bitmapConfig(Bitmap.Config.RGB_565)
.considerExifParams(true)
.displayer(new FadeInBitmapDisplayer(300))
.build();
Although you've specified the ImageView's width to match_parent
, the height is fixed to 200dp. This means if the image ratio is restricted to the height in respect to its container, the image will be horizontally padded to maintain the aspect ratio.
There are different ways to solve your problem:
fitXY
to allow the image to stretch regardless of its aspect ratio.wrap_content
to allow the height to be determined dynamically. Beware that the ViewPager's height should cope with this, for instance by being set to match_parent
.