TextInputLayout in Sketchware

To create an EditText with animation features, we can use the EditText in a TextInputLayout which is a Layout interface in android.support.design.widget library. In Sketchware we cannot add it in xml file but we can create it programmatically. Follow the instructions given below for a simple example.

1. In VIEW area of your project add two Linear horizontal linear2 and linear3, and a Button button1.

2. Switch On AppCompat and design.

3. Create a more block extra and define the block using an add source directly block. Put following code in it.
}
EditText edittext1, edittext2;
{

Here we declare two EditText fields, edittext1 and edittext2.

4. In onCreate event,
i. Use add source directly block and use codes to define edittext1, set it's LayoutParams, set it's hint, and set it's text color.
edittext1 = new EditText(this);
edittext1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
edittext1.setHint("Email");

ii. Use another add source directly block and use codes to define edittext2, set it's LayoutParams, set it's hint, set it's InputType and set it's text color.
edittext2 = new EditText(this);
edittext2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
edittext2.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
edittext2.setHint("Password");

iii. Use another add source directly block and use codes to define a TextInputLayout textinput1, set it's LayoutParams, add edittext1 to textinput1, and add textinput1 to linear2.
android.support.design.widget.TextInputLayout textinput1 = new android.support.design.widget.TextInputLayout(this);
textinput1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

textinput1.addView(edittext1);
linear2.addView(textinput1);

iv. Use another add source directly block and use codes to define another TextInputLayout textinput2, set it's LayoutParams, add edittext2 to textinput2, and add textinput2 to linear3.
android.support.design.widget.TextInputLayout textinput2 = new android.support.design.widget.TextInputLayout(this);

textinput2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

textinput2.addView(edittext2);
linear3.addView(textinput2);

5. Create two String variables email and password.


6. In the event button1 onClick, use codes to set the value of String variables to the text in EditText fields, and use the String variables in blocks to do operations on contents of the EditText fields.
email = edittext1.getText().toString();
password = edittext2.getText().toString();

7. Save and run the project.