Android:Table Row图像变胖,不保持宽高比

问题描述:

我有一个ImageView里面的TableRow,它需要基本上通过保持其纵横比来显示图像。然而,这就是我结束了:Android:Table Row图像变胖,不保持宽高比

enter image description here

这里是我的XML为TableLayout,只在特定行:

<TableLayout 
    android:id="@+id/tableLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <TableRow 
      android:id="@+id/tableRow2" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:padding="5dip" > 

       <ImageView 
        android:id="@+id/producImagScroller" 
        android:layout_width="match_parent" 
        android:layout_height="fill_parent" 
        android:background="@drawable/girl2" > 
       </ImageView> 
     </TableRow> 

你认为什么是错的?

编辑: 尝试格雷格·恩尼斯的回答后:

enter image description here

取而代之的是

android:background="@drawable/girl2" 

您应该设置

android:src="@drawable/girl2" 

做日以后是,请尝试调整图像scaleType属性。 (仅在您将background更改为src时有效)。

+0

实际上,图像是通过以下方式动态更改的:imgScroll.setImageDrawable(drawableArray [1]);这是不当行为的原因吗? – 2015-02-07 19:18:26

+0

好吧,这是一个很好的细节。setImageDrawable不会取代背景图像 - 为什么你在xml中设置背景图像?为什么2张图片? – 2015-02-07 19:19:15

+0

嗯好吧我删除了背景。仍然没有运气先生。 – 2015-02-07 19:20:16