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 course, I do not want it hard-coded, but once I can get the layout right, the rest will be easy. Can anyone help please? 开发者_如何学JAVAI would be greatly appreciated.
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>
Just use the "background" property that every View has, including TextView, to put the star(s) in. Job done.
Simply use the android:background attribute of your TextViews.
精彩评论