I'm trying to build my first calculator app with android studio, I'm familiar with Java but not with UIs and XML files. I do not understand why I have margins around the buttons that I have created.
I tried to set the layout_margin to 0 but it did not work.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="18"
tools:context=".MainActivity">
<TextView
android:id="@+id/displayTextView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:textSize="30dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:gravity="left"
android:background="@drawable/border"
/>
<TextView
android:id="@+id/finalResultTextView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:textSize="40dp"
android:layout_margin="10dp"
android:layout_weight="2"
android:background="@drawable/border"
android:gravity="center"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="3"
android:weightSum="5"
>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="C"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="\u232b"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="%"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:autoSizeMaxTextSize="60dp"
android:autoSizeTextType="uniform"
android:text="{" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="}"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="3"
android:weightSum="5"
>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="7"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:autoSizeMaxTextSize="60dp"
android:autoSizeTextType="uniform"
android:text="8"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="9"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="("
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text=")"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="3"
android:weightSum="5"
>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="4"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="5"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="6"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="/"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="*"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="3"
android:weightSum="5"
>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="1"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="2"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="3"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="-"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="+"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="3"
android:weightSum="5"
>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="."
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="0"
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="60dp"
/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:text="="
android:autoSizeTextType="uniform"
android:autoSizeMaxTextSize="100dp"
/>
/>
</LinearLayout>
</LinearLayout>
Even after I set the layout_margin to "0dp" I'm still getting margin around each button.
Here is the screenshot: