让背景小图不是拉伸而是多个重复
16lz
2021-12-04
<xml version="1.0" encoding="utf-8"?><LinearLayoutandroid: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">
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/tile"
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);
<?xml version="1.0" encoding="utf-8"?><bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@[package:]drawable/drawable_resource" android:antialias=["true" | "false"] android:dither=["true" | "false"] android:filter=["true" | "false"] android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" | "fill_vertical" | "center_horizontal" | "fill_horizontal" | "center" | "fill" | "clip_vertical" | "clip_horizontal"] android:tileMode=["disabled" | "clamp" | "repeat" | "mirror"] />
更多相关文章
- Android布局管理器
- android 安装软件
- Android的自定义长按
- Caused by: com.android.tools.r8.CompilationFailedException:
- Android(安卓)studio 导入github工程
- android中TextView和EditText控件一些属性
- Android(安卓)GPS两点间距离
- Android发送短信功能代码
- 反抗金山毒霸的代码