How can I add a TextView into an ImageView in GridView Layout?

后端 未结 3 680
野性不改
野性不改 2021-01-21 22:29

I need a GridView, but in each grid, there will be an ImageView and TextView over/inside it.

It will be like an item image in each grid, and name of the item on the imag

3条回答
  •  不知归路
    2021-01-21 22:53

    Just to extend userSeven7s' answer, you should return the RelativeLayout instead of ImageView, so that the GridView have RelativeLayout as it's direct child, instead of ImageView and RelativeLayout can have TextView and ImageView etc.
    You can get the object of RelativeLayout by the following method:

    RelativeLayout rel = (RelativeLayout)View.inflate(R.layout.YOUR_RELATIVE_LAYOUT_XML_HERE);
    

提交回复
热议问题