1

我正在尝试在 Horizo​​ntalScrollView 中创建一个 ImageView,但 imageView 的宽度是屏幕宽度的两倍,并且在一半范围内结束。

我的 XML:

<?xml version="1.0" encoding="utf-8"?>

<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/horizontalScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >


<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:baselineAligned="true"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/penguins" />
</LinearLayout>

</HorizontalScrollView>

以及我得到的图像(点击我!)

有谁知道这个问题的解决方案?

问候

4

1 回答 1

5

我复制了你的 xml 并使用我的资源,它看起来很完美,我相信你的资源比你想象的要大,你可能应该使用layout_widthlayout_height作为固定大小,并将 scaleType 设置为 centerInside。

于 2012-11-12T21:31:19.417 回答