机器人 - 如何显示的图像上文本? [英] ANDROID -- How to display text on an image?

查看:160
本文介绍了机器人 - 如何显示的图像上文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好了...所以这里的情景......从头开始,我想显示三颗星(我有一个我想使用的图像),居中。我要发布一个不同的字每颗恒星。当然,我不希望它硬codeD,但一旦我能得到的布局权,其余的将是容易的。任何人都可以帮助吗?我将不胜AP preciated。

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? I would be greatly appreciated.

推荐答案

如果你想在图像的顶部正好叠加文字,只是包装ImageView的一个的FrameLayout,然后只定义了ImageView的后一个TextView。它将被层叠在上面。因为你是在暗示你最初的问题是什么,鲁本和Yahel的答案将是更好的办法。

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.

例如:

<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>

这篇关于机器人 - 如何显示的图像上文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆