【发布时间】:2011-05-08 14:58:42
【问题描述】:
我目前有一个存储在 FrameLayout 中的 SurfaceView(名为 BoardView)。在此 FrameLayout(f1) 中存储了另一个 LinearLayout (l1),其中包含一个 EditText。我希望能够从我的 BoardView 中将 EditText 放在前面。这可能吗?我尝试使用 getParent().bringChildToFront();但它没有用。有什么想法吗?
public class Board extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//use a frame layout so you can also display a dialog box
// allows more than one view to be used
FrameLayout f1 = new FrameLayout(this);
LinearLayout l1 = new LinearLayout(this);
EditText edit = new EditText(this);
l1.setOrientation(LinearLayout.VERTICAL);
l1.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
edit.setText("Enter your name!");
l1.addView(edit);
f1.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
f1.addView(l1);
f1.addView(new BoardView(this));
setContentView(f1);
//setContentView(new BoardView(this));
}
}
【问题讨论】:
标签: android android-edittext android-linearlayout surfaceview android-framelayout