animation - android animationing views for multiple devices -


i have small game in application, if right balloons float screen, balloons views moved 2 objectanimators in animation set, , on main debugging device works fine on other devices (including tablets) looks aweful values on place , views violently sway 1 side next. here snippet of im doing:

//2 square balloons floating

            sb = (imageview)findviewbyid(r.id.squareballoon);             sb.setvisibility(view.visible);              sb2 = (imageview)findviewbyid(r.id.squareballoon2);             sb2.setvisibility(view.visible);              sp.play(inflate, 1, 1, 0, 0, 1); 

//left balloon

            objectanimator sqbalanim3 = objectanimator.offloat(sb,"x",-500,500);             sqbalanim3.setduration(700);             sqbalanim3.setrepeatcount(5);             sqbalanim3.setrepeatmode(valueanimator.reverse);              objectanimator sqbalanim = objectanimator.offloat(sb,"y",2000,-1800);             sqbalanim.setduration(3000);             sqbalanim.setrepeatmode(valueanimator.restart);              animatorset animsetxy = new animatorset();             animsetxy.playtogether(sqbalanim, sqbalanim3);             animsetxy.start(); 

//right balloon

            objectanimator sqbalanim4 = objectanimator.offloat(findviewbyid(r.id.squareballoon2),"x",-1500,-500);              sqbalanim4.setduration(700);             sqbalanim4.setrepeatcount(5);             sqbalanim4.setrepeatmode(valueanimator.reverse);              objectanimator sqbal2anim = objectanimator.offloat(findviewbyid(r.id.squareballoon2),"y",1800,-1800);             sqbal2anim.setduration(3000);             sqbal2anim.setrepeatmode(valueanimator.restart);               animatorset animsetxy2 = new animatorset();             animsetxy2.playtogether(sqbal2anim,sqbalanim4);             animsetxy2.start(); 

//balloon animation end

            animsetxy2.addlistener(new animatorlisteneradapter() {                 @override                 public void onanimationend(animator animation) {                     super.onanimationend(animation);                              sp.play(dropsound,1,1,0,0,1);                             sb.setbackgroundresource(r.drawable.burst);                             pop = (animationdrawable) sb.getbackground();                             pop.start();                             sb2.setbackgroundresource(r.drawable.burst);                             pop = (animationdrawable) sb2.getbackground();                             pop.start();                  }             });             return true;}          //end of square balloons 

ive read can use fraction rather explicit values, can me out or point in right direction, , suggestions welcome, many thanks

i guess problem in parameters using (hardcoding) like:

objectanimator.offloat(sb,"x",-500,500); objectanimator.offloat(sb,"y",2000,-1800); 

since such values device (screen actually) testing on. other devices has other screens other resolutions , should consider it. should maybe calc values dp pixels. 500 , 2000 actually? if pixels thats problem.
take here (for dp px):
what difference between "px", "dp", "dip" , "sp" on android?
android: 'dp' 'px' conversion?


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -