我试图在 HorizontalScrollView 中制作一个 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>
And a image of what I get (click me!)
有谁知道这个问题的解决方案吗?
问候
最佳答案
我复制了你的 xml 并使用我的资源,它看起来很完美,我相信你的资源比你想象的要大,你可能应该使用 layout_width
和 layout_height
作为修复大小并将 scaleType 设置为 centerInside。
关于HorizontalScrollView 中的 Android ImageView 获取屏幕宽度的两倍,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10609289/