I have to put the text over the image, I want to get the following final result:
I list all images from my database and add them dynamically to my Flexbox. But I need to do this by code, dynamically.
I have to put the text over the image, I want to get the following final result:
I list all images from my database and add them dynamically to my Flexbox. But I need to do this by code, dynamically.
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");
You can use Canvas to draw the Image and draw the text at the bottom o canvas. Check Developer Google