I'm building an injection tracking app for diabetics and other people who take regular injections, and I'm trying to align 8 checkboxes on top of an image of a body so the user can specify where they got the injection. The problem is that aligning it right now only works for a very specific screen size, and whenever the size is different, the checkboxes move around and end up not on the correct body part. Is there some way I can accomplish this? Hardcoding the margins doesn't seem to be working well. Any help would be appreciated. Thank you.
Here's what i want it to look like ideally, and here is what it actually looks like on a specific screen size which shifts everything around. It gets more extreme than that of course the larger or smaller the screen size.
and here's my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.android.injectiontracker.MainActivity">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/date_and_time_layout"
android:src="@drawable/blank_body" />
<CheckBox
android:id="@+id/abdomen_left"
style="@style/InjectionCheckbox"
android:layout_alignBaseline="@+id/abdomen_right"
android:layout_alignBottom="@+id/abdomen_right"
android:layout_toRightOf="@+id/abdomen_right"
android:layout_toEndOf="@+id/abdomen_right" />
<CheckBox
android:id="@+id/thigh_left"
style="@style/InjectionCheckbox"
android:layout_alignBaseline="@+id/thigh_right"
android:layout_alignBottom="@+id/thigh_right"
android:layout_toRightOf="@+id/thigh_right"
android:layout_toEndOf="@+id/thigh_right" />
<ImageView
android:id="@+id/save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_save_black_48dp" />
<CheckBox
android:id="@+id/buttocks_left"
style="@style/InjectionCheckbox"
android:layout_below="@+id/abdomen_left"
android:layout_alignLeft="@+id/arm_left"
android:layout_alignStart="@+id/arm_left"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp" />
<CheckBox
android:id="@+id/arm_left"
style="@style/InjectionCheckbox"
android:layout_marginRight="74dp"
android:layout_marginEnd="74dp"
android:layout_above="@+id/abdomen_left"
android:layout_toLeftOf="@+id/save"
android:layout_toStartOf="@+id/save"
android:layout_marginBottom="16dp" />
<CheckBox
android:id="@+id/buttocks_right"
style="@style/InjectionCheckbox"
android:layout_width="wrap_content"
android:layout_alignBaseline="@+id/buttocks_left"
android:layout_alignBottom="@+id/buttocks_left"
android:layout_toRightOf="@+id/buttocks_left"
android:layout_toEndOf="@+id/buttocks_left" />
<CheckBox
android:id="@+id/arm_right"
style="@style/InjectionCheckbox"
android:layout_alignBaseline="@+id/arm_left"
android:layout_alignBottom="@+id/arm_left"
android:layout_toRightOf="@+id/buttocks_right"
android:layout_toEndOf="@+id/buttocks_right" />
<CheckBox
android:id="@+id/abdomen_right"
style="@style/InjectionCheckbox"
android:layout_marginLeft="55dp"
android:layout_marginStart="55dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<CheckBox
android:id="@+id/thigh_right"
style="@style/InjectionCheckbox"
android:layout_marginTop="11dp"
android:layout_below="@+id/buttocks_left"
android:layout_alignLeft="@+id/abdomen_right"
android:layout_alignStart="@+id/abdomen_right" />