How to put a TextView inside an ImageView?

Hello little androids! I am back here again to explain you something that took me some time until I came up with the solution.

I wanted something like this… a TextView (the score) inside an ImageButton:

Captura de pantalla 2013-08-20 a la(s) 14.06.24

In order to put a TextView or whatever inside another layout component, you just have to think it in another way, which is overlapping.

How to overlap?
You just have to AlignRight and AlignTop the TextView with the ImageView in the xml file.

<ImageButton

    android:id="@+id/image_button"

    <!--... all the other attributes... -->

    />

<TextView 

    android:id="@+id/score_electronic_devices"

    <!--... all the other attributes... -->     

    android:layout_alignRight="@+id/image_button"

    android:layout_alignTop="@+id/image_button"

/>

I hope it was helpful🙂
See you soon!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s