【发布时间】:2014-02-03 00:34:01
【问题描述】:
我的图像切换器无法适应屏幕。请检查图1。屏幕边缘仍有白色可用空间。我想实现PIC 2中的效果。没有空白,图像切换器完美贴合屏幕。我可以使用 imageView 做到这一点:
android:scaleType="centerCrop"
但看起来 centerCrop 不适用于 imageSwitcher。 感谢您提供任何解决方法的想法。
更新:
这是我的 XML 代码: 我在那里添加了 android:scaleType="fitXY" 但它没有帮助。
<?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>
解决方案: 最后它帮助添加了这行代码: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;
}
【问题讨论】:
-
你能发布你的布局(xml)吗?问题可能出在持有图像的父母身上,适合您的比例类型也是 FIT_XY
-
我尝试在那里添加 FIT_XY 但它没有帮助。我更新了我的问题,所以现在你可以看到 XML 布局。你能看一下吗?谢谢。
-
如果您找到解决方案,请在此处发布并标记为已解决
标签: android screen imageswitcher