Help the program do the markup, as in the photo below. 
LinearLayout ALL = new LinearLayout(this); ALL.setOrientation(LinearLayout.VERTICAL); Toolbar.LayoutParams ALLParams = new Toolbar.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, Toolbar.LayoutParams.MATCH_PARENT); ALL.setLayoutParams(ALLParams); LinearLayout LL = new LinearLayout(this); LL.setOrientation(LinearLayout.VERTICAL); Toolbar.LayoutParams LLParams = new Toolbar.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, Toolbar.LayoutParams.MATCH_PARENT); LL.setWeightSum(6f); LL.setLayoutParams(LLParams); FrameLayout ladderFL = new FrameLayout(this); LinearLayout.LayoutParams ladderFLParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,Gravity.CENTER); ladderFL.setLayoutParams(ladderFLParams); ladderFL.setBackgroundColor(getResources().getColor(R.color.asad)); LinearLayout LL1 = new LinearLayout(this); LL1.setOrientation(LinearLayout.HORIZONTAL); Toolbar.LayoutParams LLParams1 = new Toolbar.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, Toolbar.LayoutParams.MATCH_PARENT); LL1.setWeightSum(6f); LL1.setLayoutParams(LLParams1); ladderFL.addView(ladder); LL.addView(ladderFL); LL1.addView(dummyView); LL1.addView(closeB); ALL.addView(LL1); ALL.addView(LL); RelativeLayout rl=((RelativeLayout) findViewById(R.id.relative)); rl.addView(ALL); I wrote but everything is not as it should, a lot of code, although I know that you can invest in a couple of lines, in general, I try to create markup in the first place.