Android要实现图片的水平平铺效果: 很简单也很强大,可以用布局文件也可以用代码:
下边对对应的xml中布局文件:
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/binpit_recharge_message_btn" /> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/btn_bg" /> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/binpit_recharge_message_btn" />
然后写一个配置重复平铺的配置文件放到drawable目录下:
<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/binpit_recharge_message_btn" android:tileMode="repeat" />