如何在Android中动态设置视图的位置? [英] How can I dynamically set the position of view in Android?
本文介绍了如何在Android中动态设置视图的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过代码改变视图的位置?就像改变它的 X、Y 位置一样.可能吗?
How can I change the position of view through code? Like changing its X, Y position. Is it possible?
推荐答案
对于 Honeycomb(API 级别 11)以下的任何内容,您必须使用 setLayoutParams(...)
.
For anything below Honeycomb (API Level 11) you'll have to use setLayoutParams(...)
.
如果您可以限制对 Honeycomb 及以上的支持,您可以使用 setX(...)
、setY(...)
、setLeft(...)
、setTop(...)
等
If you can limit your support to Honeycomb and up you can use the setX(...)
, setY(...)
, setLeft(...)
, setTop(...)
, etc.
这篇关于如何在Android中动态设置视图的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文