Android 表格布局自动调整图像视图

Android 表格布局自动调整图像视图,android,uiimageview,Android,Uiimageview,我使用一个表格布局来放置ImageView,我在一行中添加了5个ImageView,现在我想根据屏幕宽度自动调整所有ImageView之间的距离,我如何做到这一点,我的表格布局如下 <TableLayout android:id="@+id/tableLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/trans

我使用一个表格布局来放置ImageView,我在一行中添加了5个ImageView,现在我想根据屏幕宽度自动调整所有ImageView之间的距离,我如何做到这一点,我的表格布局如下

    <TableLayout android:id="@+id/tableLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/transparent_background">
            <TableRow android:id="@+id/tableRow1" android:layout_height="wrap_content" android:stretchColumns="*" android:layout_width="fill_parent">
                <ImageView android:layout_height="wrap_content" android:id="@+id/imageView1" android:layout_width="wrap_content" android:src="@drawable/tea"></ImageView>
                <ImageView android:layout_height="wrap_content" android:id="@+id/imageView2" android:layout_width="wrap_content" android:src="@drawable/bye" ></ImageView>
                <ImageView android:layout_height="wrap_content" android:id="@+id/imageView3" android:layout_width="wrap_content" android:src="@drawable/brb" ></ImageView>
                <ImageView android:layout_height="wrap_content" android:id="@+id/imageView4" android:layout_width="wrap_content" android:src="@drawable/pizza" ></ImageView>
                <ImageView android:layout_height="wrap_content" android:id="@+id/imageView5" android:layout_width="wrap_content" android:src="@drawable/beer"></ImageView>          
            </TableRow>             
            <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow>
            <TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow>
            <TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow>

        </TableLayout>

您好首先您必须根据分辨率获得屏幕分辨率您必须更改图像视图大小。使用此代码查找屏幕长度和高度

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth();
int height = display.getHeight();
尝试此链接,它将帮助您动态更改图像视图


您好,感谢您的指导,现在请尝试GridView,它会自动使用imageView填充布局中的剩余位置。