好吧...这就是场景...从头开始,我想显示三颗星(我有一张我想使用的图像),居中。我想在每个星标上发布一个不同的词。当然,我不希望它硬编码,但一旦我能正确布局,剩下的就很容易了。有人可以帮忙吗?我将不胜感激。
最佳答案
如果您只想在图像上叠加文本,只需将 ImageView 包裹在 FrameLayout 中,然后在 ImageView 之后定义一个 TextView。它将分层在上面。对于您在最初问题中提出的建议,Reuben 和 Yahel 的回答将是更好的方法。
例子:
<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>
关于ANDROID -- 如何在图片上显示文字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5019517/