= The diagram used to repeat the display
1. The simplest way
Create Wave_repeat.xml<?XMLversion="1.0"encoding="Utf-8"?>
<Bitmapxmlns:android="Http://schemas.android.com/apk/res/android"
android:src="@drawable/wave"
Android:tilemode="Repeat" />
use in Layout<View
Android:layout_width="Match_parent"
Android:layout_height="Wrap_content"
Android:background="@drawable/wave_repeat"/>
There is one problem with this approach, the last oneRepeatthe picture may not be a complete picture, maybe just a part.
: (About two vertical lines are added later)
2. Make sure that the last duplicate picture is complete, just a few complete same picture x axis repetitionResources res =Context. Getresources ();
Bitmap Bitmap = Bitmapfactory.decoderesource (res, r.drawable.Wave);
Holder.Viewwave. Setimagebitmap (Bitmaphelper.createrepeater (ScreenWidth, bitmap));//screenwidth for screen width (or display of picturesImageViewwidth)
methods in the Bitmaphelper.java PublicStaticBitmap Createrepeater (intwidth, Bitmap src) {
intcount = (width + src.getwidth ()-1)/Src.getwidth (); //Calculates the minimum number of repetitions required to fill the width of the tile
Bitmap Bitmap = Bitmap.createbitmap (Src.getwidth () *count, Src.getheight (), Config.argb_8888);
Canvas Canvas =NewCanvas (bitmap);
for(intidx = 0; idx < count; ++idx) {
Canvas.drawbitmap (SRC, idx * src.getwidth (), 0,NULL);
}
returnbitmap;
}
set ImageView's scaletype to fitxy in Layout
<
ImageView
Android:id="@+id/view_wave"
Android:layout_width="Match_parent"
Android:layout_height="Wrap_content"
Android:scaletype="Fitxy"/>
:
Android Image horizontal Repeat tile (repeat x)