Gis*_*453 3 animation android image screen-size
我有一个名为myimage的 ImageView 。
我正在将TranslateAnimation从一侧的屏幕外转换到另一侧的屏幕外。
Animation animation = new TranslateAnimation(0, 0, -1500, 1500);
animation.setDuration(1000);
animation.setFillAfter(false);
myimage.startAnimation(animation);
Run Code Online (Sandbox Code Playgroud)
有什么方法可以让我将它从一侧的屏幕外移动到另一侧的屏幕外,而不管屏幕大小如何?
我现在已经得到了。
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
final float screen_width_half = metrics.widthPixels/2;
final float distance = screen_width_half + 50;
//determine half screen width and add 50 to it to take it just a little outside the screen
Animation animation =
new TranslateAnimation(0, 0, -distance, distance);
animation.setDuration(1000);
animation.setFillAfter(false);
myimage.startAnimation(animation);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1391 次 |
最近记录: |