首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Android图片上的文本

Android图片上的文本
EN

Stack Overflow用户
提问于 2011-03-09 16:09:22
回答 8查看 137.6K关注 0票数 98

我有一个带有图像的imageView,我想在该图像上放置一个文本。我怎样才能做到这一点呢?

EN

回答 8

Stack Overflow用户

发布于 2011-11-25 23:23:01

这就是我是如何做到的,它的工作方式完全符合您在RelativeLayout中的要求:

代码语言:javascript
复制
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativelayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ImageView
        android:id="@+id/myImageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/myImageSouce" />

    <TextView
        android:id="@+id/myImageViewText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@id/myImageView"
        android:layout_alignTop="@id/myImageView"
        android:layout_alignRight="@id/myImageView"
        android:layout_alignBottom="@id/myImageView"
        android:layout_margin="1dp"
        android:gravity="center"
        android:text="Hello"
        android:textColor="#000000" />

</RelativeLayout>
票数 165
EN

Stack Overflow用户

发布于 2012-10-26 22:56:53

你可能想从不同的方面考虑:在背景上有一个可绘制的TextView似乎更容易:

代码语言:javascript
复制
 <TextView
            android:id="@+id/text"
            android:background="@drawable/rounded_rectangle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
        </TextView>
票数 17
EN

Stack Overflow用户

发布于 2011-03-09 16:14:19

您希望使用FrameLayout或合并布局来实现这一点。Android开发指南在这里有一个很好的例子:Android Layout Tricks #3: Optimize by merging

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5242951

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档