I am struggling with this and I cannot find a direct answer to this question due to its generic keywords leading the results to unrelated questions.
If I set a view's height or width programmatically, for example:
((Button) findViewById(R.id.myButtonId)).getLayoutParams().height = 100;
To solve this problem you should save the height before modifying it. Then when you want to reset it, you can revert to the original height. Luckily, the special cases of
WRAP_CONTENT are represented as integer constants, so this works even for those cases (credit to OP for researching this point).
So, the solution is something like this:
int initial_height = view.getLayoutParams().height;
And then when you want to set the height back to its previous value, just reference the
initial_height to do so correctly.