i would like to set position of my view. There are the methods setX/setY or setLeft/setTop but these methods are available since API 11. What is the solution in order to have this fonctionnality in other API.
问问题
2021 次
3 回答
2
这取决于您使用的布局。您RelativeLayout
可以执行以下操作:
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)child.getLayoutParams();
layoutParams.leftMargin = x;
layoutParams.topMargin = y;
child.setLayoutParams(layoutParams);
于 2013-10-21T07:56:52.763 回答
0
try to override onDraw method and set translation x/y your canvas ?
@Override
protected function onDraw(Canvas c){
c.save();
c.translate(x,y);
c.restore();
}
I think it's not a good solution but it the only idea i had.
于 2012-07-25T07:56:51.580 回答
0
我唯一可以“开箱即用”的工作就是设置视图填充。
View.setPadding(left, top, right, bottom);
这不是最好的解决方案,但它适用于 11 岁以上的 API,并且将模拟以 X、Y 方式移动视图。
希望有帮助!
于 2013-07-17T11:20:05.347 回答