为什么不应用 ImageView 高度?
我的 xml 中有两个 imageview 在线性布局中。之后我有 viewfilpper.in MotionEvent.ACTION_UP TouchEvent 我正在更改 imageview 的高度 但
((ImageView)findViewById(R.id.imgview1)).getLayoutParams().height=23;
((ImageView)findViewById(R.id.imgview1)).getLayoutParams().width=23;
((ImageView)findViewById(R.id.imgview2)).getLayoutParams().height=LayoutParams.WRAP_CONTENT;
((ImageView)findViewById(R.id.imgview2)).getLayoutParams().width=LayoutParams.WRAP_CONTENT;
在视图中,当我触摸任何 editText 字段时,就会应用更改
((ImageView)findViewById(R.id.imgview2)).invalidate();
((ImageView)findViewById(R.id.imgview2)).refreshDrawableState();
,并且通过上述语句这也不起作用,
((ImageView)findViewById(R.id.imgview1)).setLayoutParams(new LayoutParams(23,23));
((ImageView)findViewById(R.id.imgview2)).setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
我的问题没有解决
i have two imageview in my xml within linear layout.after that i have viewfilpper.in MotionEvent.ACTION_UP of TouchEvent i'm changing the height of imageview
as
((ImageView)findViewById(R.id.imgview1)).getLayoutParams().height=23;
((ImageView)findViewById(R.id.imgview1)).getLayoutParams().width=23;
((ImageView)findViewById(R.id.imgview2)).getLayoutParams().height=LayoutParams.WRAP_CONTENT;
((ImageView)findViewById(R.id.imgview2)).getLayoutParams().width=LayoutParams.WRAP_CONTENT;
but in view when i touch any editText field then changes apply
((ImageView)findViewById(R.id.imgview2)).invalidate();
((ImageView)findViewById(R.id.imgview2)).refreshDrawableState();
and this isn't working too
((ImageView)findViewById(R.id.imgview1)).setLayoutParams(new LayoutParams(23,23));
((ImageView)findViewById(R.id.imgview2)).setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
by above statements my problem isn't solved
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题在于,当您调用 getLayoutParams() 时,您会收到不可变的参数对象。考虑类似
setLayoutParamams(new LayoutParams(...))
I think the issue is that when you call
getLayoutParams()
you receive and immutable param object. Consider something likesetLayoutParamams(new LayoutParams(...))