이미지 위에 글자를 쓰고 싶은 경우에는 XML에서 ImageView 와 TextView를 사용하여 이미지위에 글자를 삽입할 수 있다. 주의해야 할점은 글자를 넣을 이미지 내부가 투명해야 하며, RelativeLayout에서만 가능하다. 세부적인 위치를 컨트롤 하고 싶을 때는 padding이나 margin을 사용하면 된다.
Android Tutorial
[Android] ImageView 위에 TextView 뿌리기 (Source 첨부)
ImageView 위에 TextView를 올려보려고 합니다.
java 소스는 건들것이 없고, layout/main.xml파일에서 FrameLayout을 사용하는 것이 포인트입니다.
1. main.xml 수정
<?xml version="1.0" encoding="utf-8"?>
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/background"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:textColor="#000000"
android:text="ImageView 위에 TextView 뿌리기"
/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
2. 결과화면