I am trying to programmatically determine the layout of my program and add a button to it in a specific position. I do not use the XML layout as a representation of the content.
RelativeLayout mainLayout; mainLayout = new RelativeLayout(this); mainLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,android.view.ViewGroup.LayoutParams.FILL_PARENT));
Then I added a button that I want to apply properties
layout align center parent align left height 60px width 60px
here is the button so far
Button BtnNext = new Button(this); BtnNext.setWidth(60); BtnNext.setHeight(60); BtnNext.setFocusable(true); BtnNext.setId(idBtnNext); BtnNext.setText("Next"); mainLayout.addView(BtnNext, 1);
Height and width do NOT work correctly.
Hamid source share