Android之背景图片设置为重复而不是默认的拉伸

在drawable目录下创建一个repeat_bg.xml:  src是引用图片的名称

<?xml version="1.0" encoding="utf-8"?>

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"

android:src="@drawable/bg"

android:tileMode="repeat" />

然后在布局的xml文件中可以这样引用:

<LinearLayout android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@drawable/repeat_bg">

</LinearLayout>

原文地址:https://www.cnblogs.com/xBig/p/4624711.html