Site icon Android Tutorial Online

Customizable EditText for Android

Setup

Add this in your root build.gradle file

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Add this to your module’s build.gradle file

dependencies {
    implementation 'com.github.omarzer0:az-edittext:0.1.0'
}

Usage

  

Properties

use “app:” before custom attr’s name

Xml AttributeTypeIn Kotlin CodeDescription
textStringtextText of the EditText
hintStringhintHint to display when text is empty
errorTextStringerrotTextError text displayed under the EditText. If this attr is not null or blank the EditText will be in the error state (border will change to the errorStrokeColor)
errorTextColorColorerrorTextColorColor of errorText
startTextStringstartTextText displayed at the start of EditText before text and after startDrawable if exists
startDrawableReferencestartDrawableThe drawable to be drawn to the start of the EditText before startText
endDrawableReferenceendDrawableThe drawable to be drawn to the start of the EditText after text
maxLenghtIntegermaxLenghtSet an input filter to constrain the text length to the specified number. Default is MAX_VALUE for int (2147483647)
inputTypeIntegerinputTypeThe type of data being placed in a text field
handlePasswordBooleanhandlePasswordWhen set to true it and inputType is one of the password input types (ex: textPassword) it handles showing and hiding password probably and showes a proper eye_closed/opened drawable
passwordShownDrawableReferencepasswordShownDrawableDrawable to show when password is visible (handle password has to be true and inputType is one of the password input types ex: textPassword)
az_textSizeDimensiontextSizeSize of the text
isEdEnabledBooleanisEdEnabledSpecifies whether the EditText is enabled
activeStrokeColorColoractiveStrokeColorColor of the border when EditText is active (text is not empty or it is focused)
inactiveStrokeColorColorinactiveStrokeColorColor of the border when EditText is inactive (text empty and it is not focused)
errorStrokeColorColorerrorStrokeColorColor of the border when EditText is in error state (when errorText is not null or blank)
containerBackgroundColorColorcontainerBackgroundColorBackground color for the EditText
containerRadiusDimensioncontainerRadiusRaduis for the border of the EditText
strokeWidthDimensionstrokeWidthStorke Width for the border of the EditText
edTextHeightDimensionedTextHeightSets a height to the text area only (android:height sets the height of the whole view)
textGravityIntegertextGravitySpecifies how to align the text by the EditText’s x- and/or y-axis when the text is smaller than the EditText

Social media

License

Copyright 2023 Omar Adel

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

GitHub

View Github

Exit mobile version