问题
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