0

我正在使用ScrollView來保存並顯示靜態地圖圖像,它的大小爲480像素x 904像素,並且已實現以便我可以上下滾動以查看地圖。我已經實現了ScrollView應該適合並填充屏幕。但是,它似乎無法拉伸地圖圖像以適應屏幕,並且我不確定我做錯了什麼。地圖圖像是僅允許右邊緣伸展的9貼圖像。ScrollView不會拉伸ImageView以適應屏幕?

下面是XML代碼:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rlayoutResultMap" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:padding="0dp" > 

    <ScrollView 
     android:id="@+id/scrollResultMap" 
     android:fillViewport="true" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:scrollbars="none" > 

     <RelativeLayout 
      android:id="@+id/rlayoutScrollMap" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" > 

      <ImageView 
       android:id="@+id/imgResultMap" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_alignParentTop="true" 
       android:src="@drawable/map_base"/> 

     </RelativeLayout> 
    </ScrollView> 

    <ImageButton 
     android:id="@+id/btnBack" 
     android:layout_width="40dp" 
     android:layout_height="40dp" 
     android:background="@android:color/transparent" 
     android:contentDescription="@string/btnBack_desc" 
     android:scaleType="centerInside" 
     android:src="@drawable/back_button" /> 

    <TextView 
     android:id="@+id/tickerWeather" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:background="#80000000" 
     android:ellipsize="marquee" 
     android:marqueeRepeatLimit="marquee_forever" 
     android:scrollHorizontally="true" 
     android:singleLine="true" 
     android:text="@string/weather_feed_init_text" 
     android:textColor="#ffffffff" /> 

    <ImageView 
     android:id="@+id/imgMapZoom" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/tickerWeather" 
     android:layout_alignParentRight="true" 
     android:layout_marginBottom="5dp" 
     android:layout_marginRight="10dp" 
     android:src="@drawable/map_zoom_icon" /> 

</RelativeLayout> 

在此先感謝。

回答

2

嘗試使用scaleType屬性ImageViewhere是文檔。

+0

謝謝!你是對的。我只需要設置scaleType =「fixXY」,一切都很好! – Kenny