简体   繁体   English

Android:表格行图像变胖且不保持宽高比

[英]Android: Table Row Image is fattened and does not maintain aspect ratio

I have an ImageView inside a TableRow which needs to basically display the image by maintaining its aspect ratio. 我在TableRow中有一个ImageView,它需要通过保持其宽高比来基本上显示图像。 However this is what I end up with: 但是,这就是我最终得到的结果:

在此处输入图片说明

Here's my XML for the TableLayout and that specific row only: 这是我的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>

What do you think is wrong? 你觉得错什么?

EDIT: After trying Greg Ennis's answer: 编辑:尝试格雷格·恩尼斯的答案后:

在此处输入图片说明

Instead of this 代替这个

android:background="@drawable/girl2" 

You should set 你应该设置

android:src="@drawable/girl2" 

After doing this, try adjusting the image scaleType attribute. 完成此操作后,尝试调整图像的scaleType属性。 (Works only if you change background to src ). (仅在将background更改为src )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM