Android 背景图片重复平铺

2023-05-24,,

有时候我们需要将一个图片横向或者纵向的平铺重复循环),这个时候我们需要创建一个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了!


Android 背景图片重复平铺的相关教程结束。

《Android 背景图片重复平铺.doc》

下载本文的Word格式文档,以方便收藏与打印。