What should I do to make the value as percent?
Like I set Button's height to 10 and it set the height in pixel but when I enter 10% it gives error(NumberFormatException).
So, what value should I write to set the height of a button to 10% ?
From your code excerpt, I would try (in pseudocode)
if requested width contains '%' then
extract int w = numeric part of requested width
set width to LENGTH_PERCENT_TAG - w
else
do whatever is currently done.
That sets up the negative length (width) attribute to satisfy the embedded code comment's calculations.
Of course, this is just off the top of my head, with no experience here.
What is the context for applying a percent width? There are a lot of moving parts in the system so knowing which one you intend to manipulate is important.