Dynamically change the width of a button in Android
I assume wrap_content doesn't work for your in your specific case, right? If you need absolute width, then you need to assign that via new LayoutParameters, i.e.
myButton.setLayoutParams(new LinearLayout.LayoutParams(
30 * someDensityFactor, LinearLayout.LayoutParams.WRAP_CONTENT
))
where the someDensityFactor is your screen density (float). You also might need to invalidate your layout then as well in order to get the button repainted.