Recently developed the app, the artist designed a jagged edge effect of the background image, only gave me a sawtooth, and then need to tile display Sawtooth effect:
There are two ways to implement tiled images in Android:
(1) Define the tiled bitmap in the drawable file in drawable
<?xml version= "1.0" encoding= "Utf-8"?> <bitmap xmlns:android=
"http://schemas.android.com/apk/res/" Android "
android:src=" @mipmap/ic_border_cupons_left "
android:tilemode=" repeat "
>
</ Bitmap>
(2) Set in code
/** * initialization sawtooth Background * @param holder/private void INITVIEWBG (Viewholder holder) {/ /Set the small rounded background of the content area tile Bitmap Topbitmap = Bitmapfactory.decoderesource (Mcontext.getresources (), R.mipmap.ic_border_cupons_
left);
Bitmapdrawable leftdrawable = new Bitmapdrawable (Mcontext.getresources (), topbitmap);
Leftdrawable.settilemodey (Shader.TileMode.REPEAT);
Bitmap Bottombitmap = Bitmapfactory.decoderesource (Mcontext.getresources (), r.mipmap.ic_border_cupons);
Bitmapdrawable rightdrawable = new Bitmapdrawable (Mcontext.getresources (), bottombitmap);
Rightdrawable.settilemodey (Shader.TileMode.REPEAT); if (Build.VERSION.SDK_INT >= build.version_codes.
Jelly_bean) {holder.favourItemBgLeft.setBackground (leftdrawable);
Holder.favourItemBgRight.setBackground (rightdrawable);
else {holder.favourItemBgLeft.setBackgroundDrawable (leftdrawable);
Holder.favourItemBgRight.setBackgroundDrawable (rightdrawable); }
}
One of the first in the XML file to set up some of the models may have an adaptation problem, so it is recommended to use code to achieve the image tiling effect.
This is the entire content of this article, I hope to learn more about Android software programming help.