将textView放在ImageView上

时间:2011-07-25 09:44:59

标签: android imageview

在Android应用程序中,我从安卓相机返回一个位图,设置为ImageView类似于:

   bitmap = android.provider.MediaStore.Images.Media
                       .getBitmap(cr, selectedImage);
                       image.setImageBitmap(bitmap);

更多我想在这张图片上放一个TextView,之后将它保存到一个网站。作为对此主题的另一个问题的回答建议在我的xml中执行此操作:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ImageView
    android:id="@+id/imageview"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scaleType="center"
    />
<TextView
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="20dip"
    android:layout_gravity="center_horizontal|bottom"
    android:padding="12dip"
    android:background="#AA000000"
    android:textColor="#ffffffff"
    android:text="Golden Gate" />

</FrameLayout>

这个问题就是当我保存图像并将其上传到网站时,textView将不会出现!!!!我认为这仅适用于手机的屏幕。 无论如何,如果有人可以帮助我,我会很感激。谢谢!!

1 个答案:

答案 0 :(得分:3)

由于您可以访问Bitmap,因此您可以将Canvas与该位图一起使用并直接在其上绘制stuf:

Canvas c = new Canvas(theBitMap);

之后,您可以使用各种画布方法将文本绘制到位图上。 e.g。

c.drawText("My Text", xCoord, yCoord, paintObj);

有关详细信息,请参阅Canvas API

相关问题