Android 背景画像の繰り返し表示

Androidで背景画像を繰り返し表示する方法のメモ。


背景画像を配置する。

res/drawable/back_img.png


xmlファイルを作成し、繰り返しを設定する。

res/drawable/back_img_repeat.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
   android:src="@drawable/back_img" 
   android:tileMode="repeat" />


レイアウトに背景を指定する。

res/layout/xxx_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/back_img_repeat">

  <!-- ..(snip).. -->
</LinerLayout>

で、できるかも。Android 1.6 APIで確認しました。


参考にしたサイト