简体   繁体   中英

Android - ImageView fit in TableLayout

How to make sure my Imageview fit in TableLayout ? Mine can't be fit like this one.

在此处输入图片说明

Mine is like this

在此处输入图片说明

My code

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:scrollbars="none" >

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <LinearLayout android:orientation="horizontal" 
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_weight="1">

                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@drawable/kelas_mengaji" />

            </LinearLayout>

        </TableRow>
</TableLayout>

</ScrollView>

将此添加到ImageView

android:adjustViewBounds="true"

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