ANDROID - How to display text on an image?

Okay ... so here is the scenario .. Starting from scratch, I want to display THREE stars (I have an image that I want to use), with the center. I want to publish another word in each star. Of course, I do not want it to be hardcoded, but as soon as I can choose the right layout, the rest will be easy. Can anyone help? I would be very grateful.

+3
source share
3 answers

If you just want to overlay text on top of the image, just wrap the ImageView in a FrameLayout, and then just define the TextView after the ImageView. It will be located on top. For what you suggest in your original question, the answers of Ruben and Yahel will be the best way.

Example:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    >
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/my_image"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Text on Top!"
        />
</FrameLayout>
+3
source

Just use the "background" property that each view has, including a TextView, to place an asterisk. Work is done.

0
source

Just use the android: background attribute of your TextViews.

0
source

Source: https://habr.com/ru/post/1792586/


All Articles