Is it possible to set in the XML layout file the size of the button so that, on one hand, it doesn’t take the entire width of the parent (screen) and, on the other hand, doesn’t use absolute pixel values?
To better explain my question, the problem in the following snippet is that "match_parent" takes the entire width:
<Button android:id="@+id/btn_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16px"
android:paddingLeft="16px"
android:paddingRight="16px"
android:paddingTop="16px"
android:text="@string/first_button" />
I know that it’s possible to control the size during runtime but I am interested to know whether this is possible in an XML file as well.
Is there something like android:layout_width="match_HALF_parent"?
The raw example could be like this:
Alternatively, you could set
android:paddingto your layout instead of margin to button.