【发布时间】:2015-04-05 10:35:42
【问题描述】:
我在 FrameLayout 中有一个 ImageView。我正在以编程方式增加 FrameLayout 的大小,但 ImageView 的大小没有改变。我已将 ImageView 参数设置为 MatchParent。请帮助我如何在 frameLayout 中增加图像的大小?
这里我已将图片添加到 FrameLayout 中:
img_pinch=new ImageView(getApplication());
img_pinch.setImageBitmap(m_bitmap);
img_pinch.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
FrameLayout fm=new FrameLayout(getApplication());
FrameLayout.LayoutParams params=new FrameLayout.LayoutParams(400,300);
fm.addView(img_pinch,params);
下面是改变frameLayout大小的代码:
int x = (int) temp_img_logo.getWidth();
int y = (int) temp_img_logo.getHeight();
temp_img_logo.setLayoutParams(new android.widget.AbsoluteLayout.LayoutParams(x+5,y+5,(int)temp_img_logo.getX(),(int)temp_img_logo.getY()));
temp_img_logo.invalidate();
temp_img_logo 是 FrameLayout 的实例。
【问题讨论】:
-
感谢@DavidJhons 的快速回复。我已发布代码,请检查并指导我如何解决我的问题。
标签: android imageview android-framelayout