InputFormTextInputLayout

InputFormTextInputLayout
InputFormTextInputLayout

InputFormTextInputLayout is a material design TextInputLayout which has a TextInputEditText as child. As an extension of TextInputLayout it allows all the functionality and configuration described in material design text fields.

InputFormTextInputLayout acts as base class for the others InputFormFields based on a TextInputLayout. This class handles the validation of the field via an InputValidator and it has these extra configurations:

  • isMandatory (false by default): if set to true, this field is not valid if let empty.
  • validateWhenFocusLost (true by default): if set to true, this field will trigger the validation when the user moves to the next field.
  • emptyErrorText: allows to change the default error message when the fields is mandatory and it is empty.

It also exposes imeOptions and inputType from its internal TextInputEditText.

Style

By default, the Android PoqSDK uses OutlinedBox style. If you want to change the style of all InputFormTextInputLayout, override the XML property BaseInputFormTextInputLayoutMaterialStyle to extend the appropriate material design style. For example, to change the default style to FilledBox, you need to replace this:

<style name="BaseInputFormTextInputLayoutMaterialStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox"/>
with this:
<style name="BaseInputFormTextInputLayoutMaterialStyle" parent="Widget.MaterialComponents.TextInputLayout.FilledBox"/>

Usage

You can set it up in the layout:

<com.poqstudio.platform.view.account.inputform.ui.PoqInputFormTextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="YourHint"
android:imeOptions="actionNext"
android:inputType="textCapWords"
android:text="@={viewModel.text}" // It allows two-way data binding
app:emptyErrorText="empty error message"
app:endIconMode="clear_text"
app:isMandatory="true" // False by default
app:validateWhenFocusLost="true" /> // True by default