我試圖建立具有滾動型,其中的圖像(遠程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