如何以编程方式调整ImageView的大小 [英] how to resize an ImageView Programmatically

查看:68
本文介绍了如何以编程方式调整ImageView的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在触摸ImageView时调整其大小.像在Google地图中或在移动浏览器中进行缩放一样,将其调整大小将是完美的,但是只要触摸它就可以调整大小.有可能吗?

I want to resize an ImageView when I touch on it. It will be perfect to resize it like when you do the zoom in google maps or in a mobile browser but if just touching it I can resize it will be enough. Is that possible?

推荐答案

只需捕获触摸此ImageView的事件即可,而不仅仅是调整高度&重量:

Just catch the event of touching this ImageView and than just adjust height & weight :

touched_image_view.getLayoutParams().height += 20;
touched_image_view.getLayoutParams().width += 20;

或者您可以只创建并设置新的LayoutParams:

Or you can just create and set new LayoutParams :

LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(100, 100);
touched_image_view.setLayoutParams(layoutParams);

希望有帮助.

这篇关于如何以编程方式调整ImageView的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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