not configure layout of these xml file. written entirely in java code above layout , someone can write it ?
------ Solution ------------------------------------ --------
challenge our intelligence you do ? want us to say the next thing to help you write
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_sec);
RelativeLayout rl = new RelativeLayout(this);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
setContentView(rl,lp);
//top view
RelativeLayout topLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams topLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,40);
topLayout.setBackgroundColor(Color.BLUE);
topLayout.setId(TOP_ID);
rl.addView(topLayout,topLParams);
//center view
RelativeLayout centerLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams centerLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
centerLayout.setBackgroundColor(Color.RED);
centerLParams.addRule(RelativeLayout.BELOW, TOP_ID);
rl.addView(centerLayout,centerLParams);
//bottom view
RelativeLayout botLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams botLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,40);
botLayout.setBackgroundColor(Color.YELLOW);
botLParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
rl.addView(botLayout,botLParams);
}
------ eference ------------------------------------- -
the top of the high is 40 , the bottom of the next 40 , the middle is automatically adapt to the screen . the best way is to use RelativeLayout using code to create .
------ eference --------------------------------------- < br> hehe. . Can say . Be sure to use the code required to write really boring ah . .
------ eference --------------------------------------- < br>
challenge our intelligence you do ? want us to say the next thing to help you write
protected void onCreate(Bundle savedInstanceState) {hey ha ha Oh, really good ah.
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_sec);
RelativeLayout rl = new RelativeLayout(this);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
setContentView(rl,lp);
//top view
RelativeLayout topLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams topLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,40);
topLayout.setBackgroundColor(Color.BLUE);
topLayout.setId(TOP_ID);
rl.addView(topLayout,topLParams);
//center view
RelativeLayout centerLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams centerLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
centerLayout.setBackgroundColor(Color.RED);
centerLParams.addRule(RelativeLayout.BELOW, TOP_ID);
rl.addView(centerLayout,centerLParams);
//bottom view
RelativeLayout botLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams botLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,40);
botLayout.setBackgroundColor(Color.YELLOW);
botLParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
rl.addView(botLayout,botLParams);
}
------ eference --------------------------------------- < br> a LinearLayout can also , more simple
------ eference ------------------------------- --------
Thanks for android these layouts , code written to understand well ,
------ eference ------------ ---------------------------
challenge our intelligence you do ? want us to help you write say Well under
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_sec);
RelativeLayout rl = new RelativeLayout(this);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
setContentView(rl,lp);
//top view
RelativeLayout topLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams topLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,40);
topLayout.setBackgroundColor(Color.BLUE);
topLayout.setId(TOP_ID);
rl.addView(topLayout,topLParams);
//center view
RelativeLayout centerLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams centerLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
centerLayout.setBackgroundColor(Color.RED);
centerLParams.addRule(RelativeLayout.BELOW, TOP_ID);
rl.addView(centerLayout,centerLParams);
//bottom view
RelativeLayout botLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams botLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,40);
botLayout.setBackgroundColor(Color.YELLOW);
botLParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
rl.addView(botLayout,botLParams);
}
I tried it in the middle painted wrong, you confirm that OK?
------ eference ---------------------- -----------------
challenge our intelligence you do ? want us to say the next thing to help you write
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_sec);
RelativeLayout rl = new RelativeLayout(this);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
setContentView(rl,lp);
//top view
RelativeLayout topLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams topLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,40);
topLayout.setBackgroundColor(Color.BLUE);
topLayout.setId(TOP_ID);
rl.addView(topLayout,topLParams);
//center view
RelativeLayout centerLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams centerLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
centerLayout.setBackgroundColor(Color.RED);
centerLParams.addRule(RelativeLayout.BELOW, TOP_ID);
rl.addView(centerLayout,centerLParams);
//bottom view
RelativeLayout botLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams botLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,40);
botLayout.setBackgroundColor(Color.YELLOW);
botLParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
rl.addView(botLayout,botLParams);
}
I tried it in the middle painted wrong, you confirm that OK?
companies try ok ah
------ eference ------------------------------- --------
challenge our intelligence you do ? want us to say the next thing to help you write
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_sec);
RelativeLayout rl = new RelativeLayout(this);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
setContentView(rl,lp);
//top view
RelativeLayout topLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams topLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,40);
topLayout.setBackgroundColor(Color.BLUE);
topLayout.setId(TOP_ID);
rl.addView(topLayout,topLParams);
//center view
RelativeLayout centerLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams centerLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);
centerLayout.setBackgroundColor(Color.RED);
centerLParams.addRule(RelativeLayout.BELOW, TOP_ID);
rl.addView(centerLayout,centerLParams);
//bottom view
RelativeLayout botLayout =new RelativeLayout(this);
RelativeLayout.LayoutParams botLParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,40);
botLayout.setBackgroundColor(Color.YELLOW);
botLParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
rl.addView(botLayout,botLParams);
}
I tried it in the middle painted wrong, you confirm that OK?
companies try ok ah
I have shown here is that the middle part is in the end , just botLayout exactly is covered in centerLayout above .
That centerLayout the bottom and the bottom is the same botLayout ,
------ eference ---------------------- -----------------
obviously you can use XML to solve the problem , have to use code to solve , do not self-flagellation ?
photographed with previously written code interface, not the usual trouble ! 2nd floor really have the patience ah !
------ eference --------------------------------------- < br> Thank 2nd floor , well, there is an attribute with the wrong ,
new to android soon learned a lot through this layout to use.
没有评论:
发表评论