2011-07-18 7 views

答えて

0

必要なのはView.layout(int,int,int,int)方法です。
Referenceは言う:

 
public void layout (int l, int t, int r, int b) 

Since: API Level 1 
Assign a size and position to a view and all of its descendants 
This is the second phase of the layout mechanism. (The first is measuring). 
In this phase, each parent calls layout on all of its children to position them. 
This is typically done using the child measurements that were stored 
in the measure pass(). 
+0

がonSensorChangedでは、私が試した 'view.layout(X、Yを、x + view.getWidth()、y + view.getHeight());各ビューでは、xとyは新しい座標で、ビューは表示されません... – jul

+0

xとyは親。ビューの幅と高さがゼロでないことを確認してください。 –

+0

彼らはそうではありません...レイアウトが呼び出されると、l、t、rとbは正しいです。しかし、その見解は示されていない。私は親を無効にしようとしましたが、何も変更されません... – jul

0

FrameLayoutは、この種のものを行うために良いではありません、あなたは次の操作を行うことができますRelativeLayoutで:

RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)child.getLayoutParams(); 

layoutParams.leftMargin = x; 
layoutParams.topMargin = y; 

child.setLayoutParams(layoutParams); 
関連する問題