I've got a problem with 2 dynamically created Layouts, the outer one being a LinearLayout which contains a relativeLayout and a Button (just for testing, will me more buttons soon).
My Relative Layout is basically a 9x9 arrangement of Buttons for a sudoku game.
My Problem now is the following, i want the relativeLayout on top of the Button, not below it. Following code places it below:
MainLayout lay = new MainLayout(this); // MainLayout is derived from RelativeLayout
LinearLayout outerLay = new LinearLayout(this);
outerLay.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
outerLay.setOrientation(LinearLayout.VERTICAL);
Button but = new Button(this);
outerLay.addView(but);
outerLay.addView(lay);
setContentView(outerLay);
This works perfectly fine, but if I rearrange them it like this:
outerLay.addView(lay);
outerLay.addView(but);
the button doesn't even show up. Anyone has a clue on this? (Same ha开发者_开发问答ppens to vertical btw.).
Greetings.
If your MainLayout lay is like :
setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
Well there is no room on screen to display anything.
Your lay is too big. Check your layoutParams of it. I hope it will help you.
精彩评论