Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding text to ImageView in Android

I want to use an ImageView to show some message in a fancy way.

How do I add text to an ImageView?

like image 541
Shashi Avatar asked Aug 04 '10 10:08

Shashi


People also ask

How do I add text to an image programmatically?

Just look at following code. First of take one view as Relative layout in that layout take ImageView after that EditText and after that button. Give each of a id. Write a loadBitmapFromView function below.

Can ImageView be clickable?

For example, you can make an ImageView act like a simple Button by adding android:onClick to the ImageView . In this task you make the images in your layout clickable.


1 Answers

To add a text to your ImageView you can do this:

<RelativeLayout> // Only works inside a RelativeLayout     <ImageView         android:id="@+id/myImageView"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/myImageSouce" />      <TextView         android:id="@+id/myImageViewText"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignLeft="@+id/myImageView"         android:layout_alignTop="@+id/myImageView"         android:layout_alignRight="@+id/myImageView"         android:layout_alignBottom="@+id/myImageView"         android:layout_margin="1dp"         android:gravity="center"         android:text="Hello"         android:textColor="#000000" />  </RelativeLayout> 
like image 187
Alesqui Avatar answered Sep 21 '22 08:09

Alesqui