Android布局背景图片无限重复

Home / Android MrLee 2014-12-12 3609

Android 背景图片重复 Background repeat 以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:



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

本文链接:https://www.it72.com/424.htm

推荐阅读
最新回复 (0)
返回