In the Android development process, the height of the control, width, although in XML with android:layout_height= "Match_parent" Set the height (match_parent and fill_parent are the same, After the 2.2 version, Match_parent was replaced with Fill_parent. But sometimes, the program needs to be in the code, dynamically set the height or width of the control.
I take it for granted setheight (100), set the height, thought this would be possible, but did not take effect, Google for a long time have no results, desperate. Later in an article found the answer.
When the height of the set is less than the original default height, call SetHeight (), is not effective, this time to set:
?
| 123 |
edittext= (EditText) Findviewbyid (r.id.myedittext); //Edittext.setheight (10); Does not take effect edittext.getlayoutparams (). Height = 100 ;//This setting takes effect. |