jobin
jobin

Reputation: 1517

android animation in different screen sizes

I am animating a layout which contains a button and a spinner using objectAnimator.In my mobile the layout moves to top.But when I tried to run the app in another mobile with larger screens size,it moved to half the screen.How can I get the x and y axis of screen .The code is below. MainActivity.java:

ObjectAnimator translate=ObjectAnimator.ofFloat(relativeLayout1,"translationY",0,-174);
                   translate.setDuration(1000);
                   translate.start();

Upvotes: 0

Views: 908

Answers (1)

SevenHuang
SevenHuang

Reputation: 31

First, access to the screen dpi,then target yoffset = target dpi / your dpi * your yoffset

Upvotes: 1

Related Questions