2011-06-11 80 views
7

我有以下機器人佈局:機器人圖像查看尺寸不與圖像縮放

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mainTopLevel" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
> 
    <ImageView 
     android:id="@+id/orbitImage" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:scaleType="fitStart" 
     android:src="@drawable/earthorbit" 
     android:padding="0dp" 
     android:background="@android:color/white" 
    /> 
    <TextView 
     android:id="@+id/positionDesc" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:minHeight="40dp" 
     android:layout_below="@id/orbitImage" 
     android:text="should appear below image" 
    /> 
</RelativeLayout> 

的圖像按比例縮小了不少,但是由於寬高比保持不變,只佔用的上半部分屏幕。

問題是,圖像視圖本身具有原始高度,這需要整個屏幕和文本從不出現。

(所以原始圖像約620 X 430,縮放後的圖像爲250×200,但圖像的看法是約250×430)

有沒有辦法讓圖像視圖的大小精確匹配圖像的縮放大小?

回答

0

由於大小由資源圖像文件固定的,那麼沒有理由爲什麼你不應該能夠解決您的ImageView高度:android:layout_height="200dp"

11

它看起來類似於這樣的問題:Android ImageView size not scaling with source image,以這對解決方案是添加android:adjustViewBounds="true"到ImageView

+0

你是一個救世主。我希望我可以投你1000倍。真的開始對此感到沮喪。如果其他人正在尋找,它也適用於gridView。 – RiddlerDev 2012-11-25 04:46:33