The effect is as follows:
Code:
<com.andye.OffcutView android:layout_width= "30DP" android:layout_height= "30DP"/ >
Public classOffcutviewextendsView {PrivateString Text = "";//private int textSize =; Private intRadius=6; PublicChampionshipoffcutview (Context context) {Super(context); } PublicChampionshipoffcutview (Context context, AttributeSet attrs) {Super(context, attrs); } PublicChampionshipoffcutview (context context, AttributeSet attrs,intDefstyle) { Super(context, attrs, Defstyle); } @SuppressLint ("Drawallocation") protected voidOnDraw (canvas canvas) {if(text==NULL) { return; } intW = getwidth (), h =getheight (); Paint Paint=NewPaint (); Paint.setantialias (true); Paint.setstyle (Paint.Style.FILL); Paint.setcolor (Color.argb (255, 69, 112, 234)); Canvas.drawcircle (RADIUS, radius, radius, paint); Path Path=NewPath (); Path.moveto (RADIUS,0); Path.lineto (W,0); Path.lineto (0, h); Path.lineto (0, RADIUS); Path.close (); Canvas.drawpath (path, paint); Canvas.save (); Textpaint Textpaint=NewTextpaint (); Textpaint.setcolor (Color.argb (255, 255, 255, 255)); Textpaint.setantialias (true); Textpaint.settextsize (W/4); floatx, y; Y=w*0.707f; Y= (y*8)/10; X=(float) (-textpaint.measuretext (Text))/2; Canvas.rotate (-45); Canvas.drawtext (Text, x, Y, textpaint); Canvas.restore (); } Public voidSetText (String str) {Text= str==NULL?"": STR; Invalidate (); } }