添加文本的ImageView Android中

问题描述:

喜 我有一个ImageView的。我想说明的显示在奇特的方式一些消息,这个图像显示。 所以我想添加文本到ImageView的。 谁能告诉我怎样才能做到这一点。

Hi I have one ImageView. I want to show this image view for showing some message in fancy way. So I want to add text to that ImageView. Can Anybody tell me how can I do this.

要一个文本添加到您的的ImageView ,你可以这样做:

To add a text to your ImageView you can do this:

<RelativeLayout> // Only works inside a RelativeLayout
    <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>