Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我的 CustomView 中使用未知(开始)数量的视图,所以我必须以编程方式设置每个视图的位置。问题是我不能使用 setX()/... 或 seTop()/... ,因为我正在为 froyo 开发。但是我该如何设置位置呢?
您RelativeLayout可以执行以下操作:
RelativeLayout
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)child.getLayoutParams(); layoutParams.leftMargin = x; layoutParams.topMargin = y; child.setLayoutParams(layoutParams);