A new Material Design text field that comes in a box, based on [Google Material Design guidelines]
Download The New Debate App [ Heatic Debate App ] Debate On Major Topics With This App.
Don’t forget to follow me on Instagram to stay up-to-date Follow Me
Sample Screen
Installation
In order to use it, you need to include it in your project.
Gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}dependencies {
implementation 'com.github.TutorialsAndroid:MTextField:v4.0.19'
}
1. Basic
Add com.developer.mtextfield.TextFieldBoxes
that contains a com.developer.mtextfield.ExtendedEditText
to your layout:
...
<com.developer.mtextfield.TextFieldBoxes
android:id="@+id/text_field_boxes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:labelText="Label"> <com.developer.mtextfield.ExtendedEditText
android:id="@+id/extended_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/></com.developer.mtextfield.TextFieldBoxes>
...
2. Enable / Disable
app:enabled
in xml or setEnabled(boolean enabled)
in Java.
<com.developer.mtextfield.TextFieldBoxes
...
app:enabled="false"
>
3. Helper Text & Error Text
NOTE: setting helper or error text to anything not empty will make the bottom view (which contains the helper label) visible and increase the height of the TextFieldBoxes. So if you want to always keep the bottom view visible (height increased), set the helper text to " "
when there should be nothing.
helper text: app:helperText
in xml or setHelperText(String helperText)
in Java.
<com.developer.mtextfield.TextFieldBoxes
...
app:helperText="Helper is here"
>
error text: setError(String errorText, boolean giveFocus)
in Java.
Param giveFocus
determines whether the field will gain focus when set error on. If true
, the field gains focus immediately.
NOTE: Error will be removed when the text changes (input or delete).
setError("Error message");
4. Prefix & Suffix
! NOTE: Prifix and Suffix attributes should be set to ExtendedEditText
.
Use app:prefix
in xml or setPrefix(String prefix)
in Java to set the unselectable prefix text at the start of the field.
Use app:suffix
in xml or setSuffix(String suffix)
in Java to set the unselectable suffix text at the end of the field.
<com.developer.mtextfield.ExtendedEditText
...
app:prefix="$ "
><com.developer.mtextfield.ExtendedEditText
...
app:suffix="\@gmail.com"
>
5. Max & Min Characters
NOTE: setting max or min character will make the bottom view (which contains the counter label) visible and increase the height of the TextFieldBoxes.
Use app:maxCharacters
in xml or setMaxCharacters(int maxCharacters)
in java code to set the max characters count. Use removeMaxCharacters()
in java code to remove the limit.
Use app:minCharacters
in xml or setMinCharacters(int minCharacters)
in java code to set the min characters count. Use removeMinCharacters()
in java code to remove the limit.
The color of the bottom line will turn to errorColor
(red by default) when exceeding max or min characters limit. 0
, as default, means no max or min characters limit.
NOTE: Space and line feed will NOT count.
<com.developer.mtextfield.TextFieldBoxes
...
app:maxCharacters="10"
app:minCharacters="5"
><com.developer.mtextfield.TextFieldBoxes
...
app:maxCharacters="5"
>
See More Functions of this library on GitHub.com