Skip to content Skip to sidebar Skip to footer

Android -- How To Display Text On An Image?

Ok...so here's the scenario.. Starting from scratch, I want to display THREE stars (i have an image that I want to use), centered. I want to post a different word in each star. Of

Solution 1:

If you're wanting to just overlay text on top of an image, just wrap the ImageView in a FrameLayout, and then just define a TextView after the ImageView. It will be layered on top. For what you're suggesting in your initial question, Reuben and Yahel's answers will be the better way.

Example:

<FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="wrap_content"android:layout_height="wrap_content"
    ><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/my_image"
        /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:text="Text on Top!"
        /></FrameLayout>

Solution 2:

Just use the "background" property that every View has, including TextView, to put the star(s) in. Job done.

Solution 3:

Simply use the android:background attribute of your TextViews.

Post a Comment for "Android -- How To Display Text On An Image?"