android animation in different screen sizes

空扰寡人 提交于 2019-12-12 03:54:49

问题


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();

回答1:


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



来源:https://stackoverflow.com/questions/35569708/android-animation-in-different-screen-sizes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!