java - One layout pushes the other one off the screen -


currently i'm working 1 small android project. ran on problem layouts because must create user interface in java. have 2 layouts first linearlayout horizontal orientation , other tablelayout. set width match parent , height wrap content both of them first 1 pushes other 1 off screen , want first layout push other 1 under him.

the code looks this:

    linearlayout mainlayout = new linearlayout(this);      linearlayout hlayout = new linearlayout(this);     hlayout.setorientation(linearlayout.horizontal);      linearlayout.layoutparams(layoutparams.match_parent,     layoutparams.wrap_content);      hlayout.setlayoutparams(params);      mainlayout.addview(hlayout);      tablelayout table = new tablelayout(this);      params = new linearlayout.layoutparams(layoutparams.match_parent, layoutparams.wrap_content);      table.setlayoutparams(params);      mainlayout.addview(table);     setcontentview(mainlayout); 

you don't seem add hlayout isn't being pushed off screen never added content view. try like

mainlayout.addview(table); mainlayout.addview(hlayout); setcontentview(mainlayout); 

also, since width match_parent , linearlayout has default orientation of horizontal, either need change orientation of mainlayout vertical or change width wrap_content.

and there reason doing programmatically? creating layouts in xml typically easier.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -