Android Text over image
I have an imageView with an image, over that image I want to place a text. How can I achieve that?
That is how I did it and it worked exactly as you asked for inside a RelativeLayout:
<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>
You may want to take if from a diffrent side: It seems easier to have a TextView with a drawable on the background:
<TextView
android:id="@+id/text"
android:background="@drawable/rounded_rectangle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
</TextView>