我试图建立具有滚动型,其中的图像(远程URL)填满屏幕(具有marginTop,marginLeft,marginRight和marginBottom设置为围绕5DP)Android应用当你向下滚动时,你会发现更多的UI组件。量表远程图像设备的高度和宽度
我发现很难将图像缩放到精确的尺寸。没有控制图像的大小。有些可能很小,有些可能很大。如果它很小,我想伸展它以适应屏幕。我的XML看起来是这样的:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ProgressBar
android:layout_width="100dp"
android:layout_height="100dp"
android:indeterminate="true"
android:layout_centerInParent="true"
android:visibility="invisible"
android:id="@+id/movieImageLoading"/>
<ImageView android:id="@+id/headerImage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitXY"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:contentDescription="@string/movie_image"></ImageView>
<Button
android:id="@+id/save2"
android:layout_width="150dp"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/headerImage"
android:text="save" />
</RelativeLayout>
这是不对的,有人可以帮我吗?
谢谢。
说“这是错误的”没有帮助。怎么了?你看到的行为是什么?理想情况下,张贴发生了什么的屏幕截图,以及你想如何看的样机 – 2013-02-19 11:31:53
嗨马特。在下面的Pratik答案中指定了行为。 屏幕截图: http://postimage.org/image/wthseojsf/ http://postimage.org/image/is2rtogah/ – sharath 2013-02-19 11:48:07
我现在还没有试过,但不应该''centerInside'是所需的scaletype ?从文档看来,它完全符合你的要求。编辑:见http://developer.android.com/reference/android/widget/ImageView.ScaleType.html – Thrakbad 2013-02-19 13:16:50