简体   繁体   中英

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. However this is what I end up with:

在此处输入图片说明

Here's my XML for the TableLayout and that specific row only:

<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. (Works only if you change background to src ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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