您的位置:首页 > 移动开发 > Android开发

让背景小图不是拉伸而是多个重复(类似于将一张小图设置电脑桌面时的效果)

2011-10-11 00:17 387 查看
 先上图:



<xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/MainLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/backrepeat"
>


backrepeat.xml

<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/repeatimg"
android:tileMode="repeat"
android:dither="true" />


代码方式:

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
BitmapDrawable bd = new BitmapDrawable(bitmap);
bd.setTileModeXY(TileMode.REPEAT , TileMode.REPEAT );
bd.setDither(true);
view.setBackgroundDrawable(bd);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android layout encoding xml
相关文章推荐