0

![在此处输入图像描述][1]我会为这个问题发疯。我无法修复图像的纵横比。我尝试了重力和矩阵,但没有保持纵横比。我该如何解决?我在 textview 中有一个可变文本(来自一个数组),我想要一个固定的图像。

<?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>
4

1 回答 1

1

你正在寻找scaleType. 将 设置scaleType为类似centerCroporcenterInside并且您的纵横比将保持不变。

更新

还要确保您src用于设置图像而不是background.

于 2013-01-17T18:49:23.350 回答