The picture shows when the total sense of the right angle of the picture is not good to see? That's a good idea! ~ ~
Public classToroundcornerextendsactivity{ PublicBitmap Toroundcorner (Bitmap Bitmap,intpixels) {Bitmap Output=Bitmap.createbitmap (Bitmap.getwidth (), Bitmap.getheight (), Bitmap.Config.ARGB_8888); Canvas Canvas=NewCanvas (output); Final intcolor = 0xff424242; FinalPaint paint =NewPaint (); FinalRect rect =NewRect (0, 0, Bitmap.getwidth (), Bitmap.getheight ()); FinalRECTF RECTF =NewRECTF (rect); Final floatROUNDPX =pixels; Paint.setantialias (true); Canvas.drawargb (0, 0, 0, 0); Paint.setcolor (color); Canvas.drawroundrect (RECTF, ROUNDPX, ROUNDPX, paint); Paint.setxfermode (NewPorterduffxfermode (PorterDuff.Mode.SRC_IN)); Canvas.drawbitmap (Bitmap, rect, rect, paint); returnoutput; }}
Put the above code in the toolkit as needed, just call it!
ImageView pic = (ImageView) navigationview.getheaderview (0). Findviewbyid (R.id.tou_pic); TextView username= (TextView) navigationview.getheaderview (0). Findviewbyid (R.id.nav_username); TextView Phone= (TextView) navigationview.getheaderview (0). Findviewbyid (R.id.nav_phone); //convert a picture into a bitmapDrawable drawable =getresources (). getdrawable (R.mipmap.aboutus); Bitmapdrawable bitmapdrawable=(bitmapdrawable) drawable; Bitmap Bitmap=Bitmapdrawable.getbitmap (); //turn a picture into rounded cornersToroundcorner Toround =NewToroundcorner (); Pic.setimagebitmap (Toround.toroundcorner (bitmap,50));
It's easy to use, isn't it? One of the last lines Toround.toroundcorner (bitmap, bitmap) is the picture to be passed in, and the larger the next number, the more visible the rounded corners.
Method excerpt from: Scripting House (http://www.jb51.net/article/32320.htm)
Android Fillet picture Implementation