在Android中如何在屏幕上的特定x-y坐标处添加视图

时间:2021-05-24 22:45:26

This is what I want to achieve. When ever a user taps at any point on the screen, I would like to show an image at that point for say 2 seconds. Is it possible ?

这就是我想要实现的目标。当用户点击屏幕上的任何一点时,我想在该点显示一个图像,比如说2秒。可能吗 ?

2 个解决方案

#1


1  

Just to inform that, I finally achieved this by overriding the onDraw method and drawing it at the specified co-ordinates

为了告知这一点,我最终通过覆盖onDraw方法并在指定的坐标处绘制它来实现这一点

#2


0  

you can use Absolute layout but it is deprecated and not recommended to use because it won't give the same reults with different screen resolutions

您可以使用绝对布局,但不建议使用它,因为它不会给出具有不同屏幕分辨率的相同结果

http://android-pro.blogspot.com/2010/02/absolute-layout.html

http://android-pro.blogspot.com/2010/02/absolute-layout.html

you can check the relative layout as a substitute

你可以检查相对布局作为替代

http://android-pro.blogspot.com/2010/02/absolute-layout.html

http://android-pro.blogspot.com/2010/02/absolute-layout.html

thanks

谢谢

#1


1  

Just to inform that, I finally achieved this by overriding the onDraw method and drawing it at the specified co-ordinates

为了告知这一点,我最终通过覆盖onDraw方法并在指定的坐标处绘制它来实现这一点

#2


0  

you can use Absolute layout but it is deprecated and not recommended to use because it won't give the same reults with different screen resolutions

您可以使用绝对布局,但不建议使用它,因为它不会给出具有不同屏幕分辨率的相同结果

http://android-pro.blogspot.com/2010/02/absolute-layout.html

http://android-pro.blogspot.com/2010/02/absolute-layout.html

you can check the relative layout as a substitute

你可以检查相对布局作为替代

http://android-pro.blogspot.com/2010/02/absolute-layout.html

http://android-pro.blogspot.com/2010/02/absolute-layout.html

thanks

谢谢