How to create this slightly complicated XML Drawable in Android? -
How can I prepare this in an XML resource file? I have tried to use a layer-list preparation, but I'm having problems with arrow processing scaling.
Is there any easy way?
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Layer-list xmlns: android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Items & gt; & Lt; Size Android: shape = "oval" & gt; & Lt; Solid Android: Color = "@color / excet_blue" /> & Lt; Size Android: width = "@ dimen / circle_thermostat_diameter_large" Android: height = "@ dimen / circle_thermostat_diameter_large" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; Items & gt; & Lt; Bitmap android: src = "@drawable / arrow_up" Android: gravity = "center" /> & Lt; / Item & gt; & Lt ;! - ... - & gt; & Lt; / Layer-list & gt;
Try it:
Increases the size of class S {path path = new path (); Float size; S (float shape) {this.size = size; } @ Override Resize at Secure Zero (Float Width, Float Height) {Float Radius = Math. (Width, height) / 2; Path.reset (); Path.moveTo (width / 2 - size, height / 2 - radius / 2); Path.rLineTo (size, size); Path.rLineTo (size, size); Path.moveTo (width / 2 - size, height / 2 + radius / 2); Path.rLineTo (size, size); Path.rLineTo (size, size); } @ Override Public Voice Draw (Canvas Canvas, Paint Paint) {Float W = Milan-Withd (); Float h = getHeight (); Float radius = monastery Minute (W, H) / 2; Paint.setStyle (Paint.Style.FILL); Paint.setColor (Color.BLUE); Canvas.drawCircle (w / 2, h / 2, radius, paint); Paint.setStrokeWidth (size / 4); Paint.setStyle (Paint.Style.STROKE); Paint.setColor (Color.WHITE); Canvas skeleton (path, paint); }}
Sample code (add it to on crate):
TextView tv = New text view (this); Tv.setGravity (Gravity.CENTER); Float size = 128; Tv.setTextSize (size); Tv.setTextColor (Color.WHITE); Tv.setText ("72"); SetContentView (TV); Tv.setBackground (New Size Drainable (New S (Size / 2));
Result:
Comments
Post a Comment