Fork me on GitHub

Android 背景图片重复平铺

有时候我们需要将一个图片横向或者纵向的平铺(重复循环),这个时候我们需要创建一个xml文件,如下:

<?xml version ="1.0" encoding ="utf-8" ?>  
<!-- 背景图片平铺 -->
<bitmap xmlns:android ="http://schemas.android.com/apk/res/android"  
   android:src ="@drawable/subtitlebg"  
   android:tileMode="repeat" />
android:src:设置需要重复平铺的图片
android:tileMode:设置图片的平铺方式,有四种方式:

然后在xml布局文件中引用该文件:

 <ImageView 
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:background="@drawable/subtitlebg_bitmap"
              />

然后运行程序就ok了!




posted on 2015-01-28 21:04  骑着乌龟漫步  阅读(936)  评论(0编辑  收藏  举报

导航