Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to set button width to the wrap_content or match_parent in the android from java code?
Posted

1 solution

Use the following method:
Java
Button myButton = (Button) findViewById(R.id.buttonid);
LayoutParams buttonparam = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,1.0f);
myButton.setLayoutParams(buttonparam);

LayoutParams(layout_width,layout_height,layout_weight);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900