I thought about it too, but the width of my GridView is not set to a fixed value. Now it is content-adaptive. And I also tried to get the width of the GridView, but the value obtained is not fixed, with values ranging from 1000 to 200 to 500. Not sure what's going on...
The width of the gridview should fill up the parent container. If you know the number of columns displayed by the gridview below, then you can use LinearLayout to nest the Imageview above, set the weight of the Imageview, and that's it.
Isn’t the width of Imageview the same as the width of grpiew?
I thought about it too, but the width of my GridView is not set to a fixed value. Now it is content-adaptive. And I also tried to get the width of the GridView, but the value obtained is not fixed, with values ranging from 1000 to 200 to 500. Not sure what's going on...
The width of the gridview should fill up the parent container. If you know the number of columns displayed by the gridview below, then you can use LinearLayout to nest the Imageview above, set the weight of the Imageview, and that's it.