In: Computer Science
Create and display an XML file in Android studio that has
-One edittext box the does NOT use material design
-One edittext box that DOES use material design
Provide a “hint” for each, and make sure the string that comprises the hint is referenced from the strings.xml file.
Observe the differences in how the hints are displayed.
Here is sample code for a material design editText:
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_price1Text"
android:layout_width="80dp"
android:layout_height="40dp"
>
<EditText
android:id="@+id/price1Text"
android:importantForAutofill="no"
tools:targetApi="o"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="6"
android:inputType="numberDecimal"
android:hint="@string/hint_text"
/>
</android.support.design.widget.TextInputLayout>
It requires this to be added to the build.gradle Module:app
implementation 'com.android.support:design:28.0.0'
Take a screenshot, Make sure the screenshot clearly shows the two different ways that the hints are displayed.
actyivity_main.xml
<?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"> <com.google.android.material.textfield.TextInputLayout android:id="@+id/input_layout_price1Text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="16dp" android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/price1Text" android:layout_width="match_parent" android:layout_height="wrap_content" android:importantForAutofill="no" android:ems="6" tools:targetApi="o" android:hint="@string/material_edittext_hint" android:padding="20dp" /> </com.google.android.material.textfield.TextInputLayout> <EditText android:id="@+id/price2Text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginTop="32dp" android:layout_marginEnd="8dp" android:hint="@string/normal_edittext_hint" android:importantForAutofill="no" android:inputType="numberDecimal" android:padding="20dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/input_layout_price1Text" /> </androidx.constraintlayout.widget.ConstraintLayout>
****************************************************************** SCREENSHOT *********************************************************