0

I have an android project in which I use the camera and save tho photo in a imageView. So, I want to paste some text over this imageView. It's possible ??

user2550055
  • 39
  • 1
  • 7

4 Answers4

1

Write something like this inside your RelativeLayout:

<ImageView
    android:id="@+id/myImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/imageSouce" />

<TextView
    android:id="@+id/textview1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textview1"
    android:layout_alignTop="@+id/textview1"
    android:layout_alignRight="@+id/textview1"
    android:layout_alignBottom="@+id/textview1"
    android:layout_margin="1dp"
    android:gravity="center"
    android:text="Hello"
    android:textColor="#000000" />

Or, Want to do it programmatically?Then follow..

Community
  • 1
  • 1
ridoy
  • 6,274
  • 2
  • 29
  • 60
0

Create a RelativeLayout or FrameLayout containing your ImageView and a TextView. The TextView will appear over the ImageView.

techi.services
  • 8,473
  • 4
  • 39
  • 42
0

Use TextView and set the image background to the text view.

or

If you want to use image view then create TextView and place both TextView & ImageView in a RelativeLayout.

techi.services
  • 8,473
  • 4
  • 39
  • 42
Uma
  • 422
  • 4
  • 5
0

Follow these steps :

Step 1 : First Change the layout to RelativeLayout

Step 2 : Click and drag the imageview button inside your workspace and select the image you have stored in your drawable folder.

Step 3 : Choose TextView and drag it into your centre of the image. (Rightclick-EditText-Change into ur desired Text).

You can also use textStyle or textSize to make the text as big and for formatting.

Here is the simple sample code :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/sm" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/imageView1"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="148dp"
    android:textStyle="bold"
    android:text="Here is my text " />

</RelativeLayout>

Result :

enter image description here

ridoy
  • 6,274
  • 2
  • 29
  • 60
Yuva Raj
  • 3,881
  • 1
  • 19
  • 30