Thursday, February 13, 2014

AbsoluteLayout dynamically add controls absolute layout problem


            
Requirements are: a series of self-control to write dynamically add location information to the layout, the following code can only display the last control, hope someone can help greatly appreciated! :

private void LocationKeys (ArrayList keys) {
AbsoluteLayout.LayoutParams keyLp = (android.widget.AbsoluteLayout.LayoutParams) new LayoutParams (0, 0, 0, 0);
for (Key key: keys) {
key.setId (key.getId ());
key.setImageBitmap (key.getBttnImg ());
keyLp.width = key.getBttnImg () getWidth ();.
keyLp.height = key.getBttnImg () getHeight ();.
keyLp.x = key.getKeyLocation () getI () * this.screenWidth / horizontalNum;.
keyLp.y = key.getKeyLocation () getJ () * this.screenWidth / verticalNum;.

Log.d (debug, "keyLp.width =" + keyLp.width);
Log.d (debug, "keyLp.height =" + keyLp.height);
Log.d (debug, "keyLp.x =" + keyLp.x);
Log.d (debug, "keyLp.y =" + keyLp.y);

this.abslyt.addView (key, keyLp);
}

this.setContentView (abslyt);
}
Reply:
Print out the coordinates and the width and height is no problem now,

You look abslyt the x, y, width, height there is no problem
Reply:
cited a floor chen515272204 reply:
print out the coordinates and the width and height is no problem now,

You look abslyt the x, y, width, height have no problem



No problem, the single button layout up no problem, but it covers the controls before, but definitely layout can be configured through XML coexistence of multiple controls, tried other layouts, seems to have failed to meet this demand
Reply:
abslyt of x, y, width, height, if there is no problem, and the x, y coordinates keyLp's no problem, then it is a bit strange, or you may have to add each view including absly background color to see in the end what Song of the case
Reply:
AbsoluteLayout components added after originally covered before, headache ah, why make such a pinch, with stacks like. . java layout really is not. NET cool, knot stickers get points. . .
Reply:
Eritrea That is, do not know what features you want to achieve, there FrameLayout this layout, lz can see if you can meet your
Reply:
The more rigid, my needs are dynamically layout, controls can move freely, to think of all the absolute positioning
Reply:
I also encountered the same problem. Will Big Brother still remember how to solve it?
Reply:
I define the layout of the controls to be applied to the absolute inside, calling addView () after, onMesure and onLayout child controls are invoked, but do not call
onDraw

No comments:

Post a Comment