不同屏幕尺寸的android动画 [英] android animation in different screen sizes

查看:117
本文介绍了不同屏幕尺寸的android动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用objectAnimator对一个包含按钮和微调器的布局进行动画处理。在我的手机中,该布局移至顶部。但是当我尝试在另一台具有更大屏幕尺寸的手机中运行该应用程序时,它移到了一半的屏幕。如何获得屏幕的x和y轴。代码如下。
MainActivity.java:

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


推荐答案

首先,访问屏幕dpi,然后目标yoffset =目标dpi /您的dpi *您的偏移量

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

这篇关于不同屏幕尺寸的android动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆