Skewing a text view in Android -
i'm looking replicate following within application:
as can see, button increases/decreases value of text view contained within it. button have 3 visual states -> unpressed, decrease , increase (as seen in image above, user taps increase arrows , button appears pressed in on side)
here 3 button states currently:
as can see, problem have being able correctly skew/rotate text view looks visually correct , appears slanted along button when being increased or decreased.
i have tried 2 different approaches far:
-
create custom text view class overrides
ondraw()
method skew canvas:@override public void ondraw(canvas canvas) { canvas.save(); canvas.skew(0.2f, 0f); super.ondraw(canvas); canvas.restore(); }
-
integrate
rotate3danimation
class (source here) , used many different variations desired result such as:rotate3danimation skew = new rotate3danimation( 30, 0, centerx, centery, 0, false); txtamount.startanimation(skew);
unfortunately, i'm not quite getting exact result mirrors first image above. i'm getting confused setting values z-axis, skew, rotate etc.
i'd appreciate has experience stuff. in advance
well tried , came this:
public class demoactivity extends textview { context context; string firsttext = "$120.00"; public demoactivity(context context) { super(context); this.context = context; } @override protected void ondraw(canvas canvas) { super.ondraw(canvas); settext(firsttext); settextsize(30); canvas.skew(1.0f, 0.3f); //you need change values on here rotate3danimation skew = new rotate3danimation( -20, 30,200, 200, 0, false); //here startanimation(skew); } }
i got output as:
i guess changing values trial , error can solve problem. hope helps.
Comments
Post a Comment