ANDROID — How to display text on an image?

后端 未结 3 1509
独厮守ぢ
独厮守ぢ 2021-01-06 16:12

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 s

相关标签:
3条回答
  • 2021-01-06 16:46

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

    0 讨论(0)
  • 2021-01-06 16:50

    Simply use the android:background attribute of your TextViews.

    0 讨论(0)
  • 2021-01-06 16:58

    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:

    <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>
    
    0 讨论(0)
提交回复
热议问题