2013-01-17 70 views
0

![這裏輸入圖片描述] [1]我要瘋了這個問題。我無法修復圖像的縱橫比。我嘗試了重力和矩陣,但沒有保持縱橫比。我如何解決?我有一個TextView中的變量文本(來自數組),我想要一個固定的圖像。長寬比imageview

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#000000" 
android:orientation="vertical" > 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:orientation="vertical" > 

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/luna1" 
    android:textSize="15pt" 
    android:layout_weight="1"/> 

<ScrollView 
    android:id="@+id/scrollView10" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" 
    android:layout_gravity="center" 
    android:background="#000000" 
    android:layout_weight="1" > 

    <TextView 
     android:id="@+id/textView10" 
     android:layout_width="match_parent" 
     android:layout_height="320dp" 
     android:background="#000000" 
     android:gravity="center" 
     android:textColor="#ffffff" 
     android:textSize="14sp" 
       android:text="jjkjkljkjkldjklsdfjkljklsdfjklsdfjklsdfjklsdfjklsdfjklsdfjklfjlsdfjkl" 
     android:autoLink="web|email" 
     android:textStyle="italic" /> 
</ScrollView> 
</LinearLayout> 

<Button 
android:id="@+id/button10" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:text="Chiudi" /> 

</LinearLayout> 

回答

1

您正在尋找scaleType。將scaleType設置爲centerCropcenterInside之類的內容,並且您的寬高比將保持不變。

更新

另外,還要確保你使用src設置你的形象,而不是background

+0

我只是試過,但我也有同樣的問題。感謝 –

+0

你把'ImageView'的'scaleType'設置爲'centerCrop',你的縱橫比是否改變? – kabuko

+0

我附上了截圖。 「月亮」應該是圓形的。 –