Sunday, April 20, 2014

How to use the code to write such a layout interface?



These are not configured layout xml files. Written entirely in java code above layout, someone can write out?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
High top 40, the bottom is under 40, the middle is automatically adapted to the screen. Preferably, created with code using RelativeLayout way.
Reply:
cited a floor xiangding reply: High
top 40, the bottom is under 40, the middle is automatically adapted to the screen. Preferably, created with code using RelativeLayout way.

Your challenge our intelligence it? Want us to help you write the next thing to say
 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);





}

Reply:
Hehe. . Can say. Be sure to use the code required to write really hurt the eggs. .
Reply:
reference to the second floor guoyoulei520 reply:
Quote: references to a floor xiangding reply:

High top 40, the bottom is under 40, the middle is automatically adapted to the screen. Preferably, created with code using RelativeLayout way.

Your challenge our intelligence it? Want us to help you write the next thing to say
 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);





}
hey ha ha Oh, really good ah.
Reply:
A LinearLayout also be more simple
Reply:
Thank you for android these layouts, code written to understand well,
Reply:
reference to the second floor guoyoulei520 reply:
Quote: references to a floor xiangding reply:

High top 40, the bottom is under 40, the middle is automatically adapted to the screen. Preferably, created with code using RelativeLayout way.

Your challenge our intelligence it? Want us to help you write the next thing to say
 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 the middle painted wrong, you confirm that OK?
Reply:
reference to the 7th floor xiangding reply:
Quote: references to the second floor guoyoulei520 reply:

Quote: references to a floor xiangding reply:

High top 40, the bottom is under 40, the middle is automatically adapted to the screen. Preferably, created with code using RelativeLayout way.

Your challenge our intelligence it? Want us to help you write the next thing to say
 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 the middle painted wrong, you confirm that OK?

Companies try ah ok
Reply:
reference to the 8th floor guoyoulei520 reply:
Quote: references to the 7th floor xiangding reply:

Quote: references to the second floor guoyoulei520 reply:

Quote: references to a floor xiangding reply:

High top 40, the bottom is under 40, the middle is automatically adapted to the screen. Preferably, created with code using RelativeLayout way.

Your challenge our intelligence it? Want us to help you write the next thing to say
 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 the middle painted wrong, you confirm that OK?

Companies try ok ah

I have shown here is the middle part is in the end, and just happens to be covered in centerLayout botLayout above.
That centerLayout the bottom and botLayout the bottom is the same,
Reply:
Obviously you can use XML to solve the problem, have to use code to solve, not self-flagellation it?
Previously written code to interface with the camera, not the usual trouble! 2nd Floor patience really ah!
Reply:
Thanks to the second floor, well, there is an attribute with the wrong,
New to android soon, learned to use a lot through this layout.

No comments:

Post a Comment