0

I have to put the text over the image, I want to get the following final result:

Example result

I list all images from my database and add them dynamically to my Flexbox. But I need to do this by code, dynamically.

Harald K
  • 26,314
  • 7
  • 65
  • 111
HaMan
  • 13
  • 2

2 Answers2

0

You can use this:

<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="Default text"
    android:textColor="#000000" />

And dynamically change Text in this image using:

TextView myAwesomeTextView = (TextView)findViewById(R.id.myImageViewText);

myAwesomeTextView.setText("New Text inside Image");
Francesco Bocci
  • 827
  • 8
  • 19
0

You can use Canvas to draw the Image and draw the text at the bottom o canvas. Check Developer Google

Cliff
  • 682
  • 8
  • 30