Skewing a text view in Android -


i'm looking replicate following within application:

enter image description here

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:

enter image description hereenter image description hereenter image description here

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:

enter image description here

i guess changing values trial , error can solve problem. hope helps.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -