简体   繁体   English

如何以编程方式调整ImageView的大小

[英]how to resize an ImageView Programmatically

I want to resize an ImageView when I touch on it. 我想在触摸时调整ImageView的大小。 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? 那可能吗?

Just catch the event of touching this ImageView and than just adjust height & weight : 只需触摸触摸此ImageView的事件,而不仅仅是调整高度和重量:

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

Or you can just create and set new LayoutParams : 或者您可以创建和设置新的LayoutParams:

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

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM