title: Android background sizes - resizing to fit all devices
body: <p>this is a slightly different question to other background image sizing questions asked before. On this fragment when the user selects an icon the background image changes dynamically on each click. For example if the user clicks an icon of the sun the background will change to a sunny one, if they click a cloud icon the background will change to cloudy and so on. </p>
  
  <p>I use a simple switch statement to achieve this:</p>
  
  <pre><code>@Override
  public void onMoodClick(int position) {
  
      switch (position) {
          case 0:
              moodBefore = 1;
              backgroundChanger.setImageResource(R.mipmap.background_clouds_excited);
              hasSelected = true;
              break;
  
          case 1:
              moodBefore = 2;
              backgroundChanger.setImageResource(R.mipmap.background_clouds_happy);
              hasSelected = true;
              break;
  </code></pre>
  
  <p>The problem is: it looks perfect on the emulator which is set up as a pixel 2. However when I load the app onto my Galaxy s10 I notice that part of the background is getting chopped off. So like only half the sun is visible on my s10 but the full background is visible on the pixel 2 emulator. Would anyone know a potential fix for this issue so the backgrounds are a little more dynamic and can accommodate different screen sizes?</p>
  
  <p>LAYOUT:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout   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:id="@+id/FragmentWorkoutMood2"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".ui.fragments.WorkoutFragment"&gt;
  
  &lt;com.example.feelingfit.utils.CropImageView
      android:id="@+id/workoutBackground"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:scaleType="matrix"
      android:src="@mipmap/background_clouds_workout_default"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" /&gt;
  </code></pre>