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
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);
Create a RelativeLayout
that contains the ImageView
and the TextView,with TextView's bottom edge aligned with the Imageview's
bottom edge.
<RelativeLayout ...>
<ImageView ...>
<TextView ...
android:layout_alignBottom="id of the imageview"> // or to top
</RelativeLayout>
Inflate this layout in getView
method of your adapter.
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/grid_outer_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/image_border" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<TextView
android:id="@+id/grid_inner_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="some text" />
</RelativeLayout>
</RelativeLayout>