Android: imageSwitcher fit on screen
android, imageswitcher, screen
Solution
SOLUTION: finally it helped add this line of code: imageView.setScaleType(ImageView.ScaleType.FIT_XY);
public View makeView() {
ImageView imageView = new ImageView(Introduction.this);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
LayoutParams params = new ImageSwitcher.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
imageView.setLayoutParams(params);
return imageView;
}
Problem
I have a problem with imageswitcher to fit on screen. Please check PIC 1. There is still white free space on the edge of the screen. I want to achieve the effect in PIC 2. There is no empty space and imageswitcher perfect fit to screen. I can do this efect with imageView using: ``` android:scaleType="centerCrop" ``` but it looks centerCrop doesn't works with imageSwitcher. Thanks for any idea how to fix it. UPDATE: Here is my XML code: I added there android:scaleType="fitXY" but it didn't help. ``` <?xml version="1.0" encoding="utf-8"?> <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:orientation="vertical" > <ImageSwitcher android:id="@+id/imageswitcher" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitXY" android:src="@drawable/it_intro1" > </ImageSwitcher> ``` SOLUTION: finally it helped add this line of code: imageView.setScaleType(ImageView.ScaleType.FIT_XY); ``` public View makeView() { ImageView imageView = new ImageView(Introduction.this); imageView.setScaleType(ImageView.ScaleType.FIT_XY); LayoutParams params = new ImageSwitcher.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); imageView.setLayoutParams(params); return imageView; } ```