开发者

How i detemine Button (x,y) cords in Layout?

I Have this simple Code:

    layout = new RelativeLayout(this);
    bottom = new Linear开发者_运维百科Layout(this);
    Button close = new Button(this);
    close.setText("Close");
    bottom.addView(close);
    layout.addView(bottom);
    setContentView(layout);
  • How can i put my button at the bottom of the window i prefer to determine the x,y cords but any solution will be good. since the absoluteLayout is deprecated i tried using the Relativelayout as the api adviced with no succes.

  • i'm not using XML at all is that a problem ?


You can set LayoutParametrs (RelativeLayout.LayoutParams) to your elements. And don't forget to set LayoutParams to parent view.

RelativeLayout.LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

lp.addRule(ALIGN_PARENT_BOTTOM);

button.setLayoutParams(lp)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜