画面に収まらないイメージスイッチャーに問題があります。PIC 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;
}