Reputation: 1439
trying to set layout params but did not find any suitable method to set width and height as wrap_content
programmatically. How to do this
public void populateGrid(){
GridLayout grid = new GridLayout(this);
//now here i want to set layout_width and layout_height as wrap_content
grid.setColumnCount(columnCount);
for(int i=0; i<floors.size(); i++){
...
}
}
Upvotes: 2
Views: 1746
Reputation: 12615
You can do that by using setLayoutParams()
method
grid.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Upvotes: 2