ImageView的,并设置位置

编程入门 行业动态 更新时间:2024-10-13 16:20:37
本文介绍了ImageView的,并设置位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在活动ImageView的。如何设置这个位置中的ImageView我的活动。我知道我可以在XML文件中做到这一点,但我想这样做的活动,因为我有onTouch方法,其中我得到我的地方点击坐标,我想在这个坐标绘制这个图像。

I have imageView in activity. How I can set position this imageView in my activity. I know how I can do this in xml file but I want to do this in activity, because I have onTouch method where I get coordinates where I clicked and I want to draw this images in this coordinates.

推荐答案

@ edi233--

@edi233--

我觉得你可以触摸X'放大器; Ÿ这样就可以计算上边距和放大器;左边距。我认为,(0,0)将在左上角,所以如果你触摸(100,75),你需要图像视图距设置顶部 - 75安培;留给100

I think you can get touch x & y so that you can calculate top margin & left margin. I think (0,0) will be left top corner so if you touch (100,75) you need to set margins of image view to top - 75 & left to 100

LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.setMargins(100,75, 0,0); // OR params.topMargin= 100; image.setLayoutParams(params);

更多推荐

ImageView的,并设置位置

本文发布于:2023-10-08 01:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471086.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位置   ImageView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!