展会信息港展会大全

Android 背景图片重复 Background repeat
来源:互联网   发布日期:2015-10-02 16:02:24   浏览:1877次  

导读:以LinearLayout为例,它提供的background属性将会将背景图片拉伸,相当难看。事实上我们只需做少量的修改就可以实现web编程中css背景图片的效果。来试试吧。Bitmap介绍A Drawable that wraps a bitmap and......

以LinearLayout为例,它提供的background属性将会将背景图片拉伸,相当难看。事实上我们只需做少量的修改就可以实现web编程中css背景图片的效果。来试试吧。

Bitmap介绍

A Drawable that wraps a bitmap and can be tiled, stretched, or aligned. You can create a BitmapDrawable from a file path, an input stream, through XML inflation, or from a Bitmap object.

属性 android:tileMode

Defines the tile mode. When the tile mode is enabled, the bitmap is repeated. Gravity is ignored when the tile mode is enabled.

Constant Value Description

disabled -1 Do not tile the bitmap. This is the default value.

clamp 0 Replicates the edge color.

repeat 1 Repeats the bitmap in both direction.

mirror 2 Repeats the shader s image horizontally and vertically, alternating mirror images so that adjacent images always seam.

创建重复的背景图片

在drawable目录下创建一个repeat_bg.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 android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@drawable/repeat_bg">

;</LinearLayout>

创建横向重复的背景图repeat-x

创建纵向重复的背景图repeat-y

赞助本站

人工智能实验室

相关热词: 背景图片 Background repeat

相关内容
AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港