How to change the existing width of a button programmatically to 1/3 of the width of the screen at maximum. By saying ‘at maximum’ I mean that if there will be enough space for a button to be 1/3 of the screen it should be resized. Otherwise the button should fit in the existing space gap (it can be for example 1/4 or even 1/5 of the screen’s width).
EDIT: I'm looking for a soultion for RelativeLayout.