实现图片重复效果
1、原图
效果图:
2、实现:
1)原图:crop__tile.png
2)定义drawable:crop__texture.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/crop__tile"
android:tileMode="repeat" />
3)使用,注意是background
<ImageView
android:id="@+id/crop_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/crop__texture"
/>
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/crop__tile"
android:tileMode="repeat" />
3)使用,注意是background
<ImageView
android:id="@+id/crop_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/crop__texture"
/>
本文介绍如何在Android中利用XML资源文件实现图片的重复显示效果。通过定义一个特殊的Drawable资源,可以使得ImageView中的背景图片在水平和垂直方向上重复显示,达到装饰UI的目的。
1247

被折叠的 条评论
为什么被折叠?



