安卓图片背景重复

标签 android background-image repeat

我有一个用于 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/

相关文章:

java - Eclipse自定义程序构建链——添加源文件

Android,如何正确制作透明状态栏

java - csv文件到android中的JSONArray

c - 使用 C UDP 套接字的选择性重复 ARQ

R 循环使用牛顿法近似正实数的平方根

java - 动态添加按钮到ScrollView android

android - 按钮背景图像拉伸(stretch)(wrap_content 或 dp 使用)

jquery - 使用 css3 或 jquery 的背景图像动画?

html - 带旋转、重复和不透明度的 CSS 背景图像

javascript - 如何用时钟重复一个javascript函数