纵横比imageview

时间:2013-01-17 18:37:45

标签: android

![在此处输入图像描述] [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>

1 个答案:

答案 0 :(得分:1)

您正在寻找scaleType。将scaleType设置为centerCropcenterInside,并保持宽高比。

<强>更新

另外,请确保您使用src来设置图片,而不是background