How can I set a fixed width for an Android button? Everytime I try to set a fixed width it fills the current parent (the RelativeView). Here is my XML:
Instead of android:layout_width="wrap_content"
you can use a fixed pixelsize like for example android:layout_width="20px"
or a better way: android:layout_width="20dp"
you can also set the width programatically in the code: Button.setWidth(int width)
Concerning your update:
I don't know if it is a good solution, but i works. You could use
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
to read the screen resolution and then set the button sizes according to metrics.widthPixel and metrics.heightPixel