Resize imageViews in a grid layout

北战南征 提交于 2019-12-11 05:05:47

问题


I'm trying to create a Tria games in android. I have created a grid layout with 3 rows and 3 columns. Inside the cells there 9 square imageViews. I want occupy all the space of the grid layout, and the images must have the same dimensions. How can I do this?

There is the layout

<GridLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:columnCount="3"
            android:rowCount="3">

and this is a sample of an imageView

<ImageView
                android:id="@+id/imageView9"
                android:layout_width="48dip"
                android:layout_height="48dip"
                app:srcCompat="@drawable/android" />

(48dip is for an experiment)


回答1:


Instead of giving fixed width and hight give in term of Weight

 android:layout_weight="1"


来源:https://stackoverflow.com/questions/42877005/resize-imageviews-in-a-grid-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!