Skip to content

Instantly share code, notes, and snippets.

@swaroopjcse
Created September 9, 2021 06:11
Show Gist options
  • Save swaroopjcse/7d71d01587b40930dbf3bdf4a00f4ccb to your computer and use it in GitHub Desktop.
Save swaroopjcse/7d71d01587b40930dbf3bdf4a00f4ccb to your computer and use it in GitHub Desktop.
Starter code for the Units app for teaching Testing in Android
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/switch_c_f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:minWidth="48dp"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="@+id/txt_c2f"
app:layout_constraintEnd_toStartOf="@+id/txt_f2c"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/txt_c2f"
app:layout_constraintTop_toTopOf="@+id/txt_c2f" />
<TextView
android:id="@+id/txt_c2f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/c2f"
app:layout_constraintBottom_toTopOf="@+id/edit_input"
app:layout_constraintEnd_toStartOf="@+id/switch_c_f"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="@+id/txt_f2c"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:text="@string/f2c"
app:layout_constraintBottom_toBottomOf="@+id/switch_c_f"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/switch_c_f"
app:layout_constraintTop_toTopOf="@+id/switch_c_f" />
<EditText
android:id="@+id/edit_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:autofillHints="Signed Decimal Number"
android:ems="10"
android:hint="@string/input_value"
android:inputType="numberDecimal|numberSigned"
android:minHeight="48dp"
android:textAlignment="center"
app:layout_constraintBottom_toTopOf="@+id/btn_convert"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txt_c2f"
tools:ignore="TextContrastCheck" />
<Button
android:id="@+id/btn_convert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/convert"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edit_input" />
<TextView
android:id="@+id/txt_output"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_convert" />
</androidx.constraintlayout.widget.ConstraintLayout>
<resources>
<string name="app_name">Units</string>
<string name="c2f">C2F</string>
<string name="f2c">F2C</string>
<string name="convert">Convert</string>
<string name="input_value">Input Value</string>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment