我有一个用于 LinearLayout 背景的图像 假设图片有 20x100 像素 我想让图像只在 x 轴上重复......在 css 中是这样的
background-repeat:repeat-x;
LinearLayout 有点大(1024 x 680 像素)所以我的图像将覆盖整个宽度但只覆盖顶部(其余 580 像素的高度将是透明的) 我希望我是清楚的 谢谢
最佳答案
尝试使用 android:tileMode
在 drawable 文件夹中创建 background.xml
为:
<?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
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:orientation="vertical" >
关于安卓图片背景重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9279012/