Android Field Input

Library for android. FieldInput is layout component base on ViewGroup LinearLayout for get input from user.

Installation

Add it in your root build.gradle at the end of repositories:

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

Add the dependency:

dependencies {
	implementation 'com.github.fajaragungpramana:field-input:0.0.4'
}
Gradle

Usage

Define a view in your layout file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.github.fajaragungpramana.field.FieldInput
        android:id="@+id/field_input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="16dp"
        android:layout_marginTop="16dp"
        app:drawableEnd="@drawable/ic_barcode"
        app:focusable="true"
        app:hint="@string/app_name"
        app:inputType="text"
        app:textAllCaps="false"
        app:textColor="@color/black"
        app:textSize="14sp" />

</LinearLayout>
XML

Handle drawable click listener.

fieldInput.setOnClickDrawableListener(DrawablePosition.END) {
	Log.d(MainActivity::class.simpleName, "Drawable ${DrawablePosition.END} Clicked!")
}
Kotlin

Get or do something when user is still typing text.

fieldInput.setOnTextChanged { text ->
	// Do something hire when user still typing
}
Kotlin

Set error message.

fieldInput.errorMessage = "Type something error message here!"
Kotlin

Set or get text input.

fieldInput.text // Do this to get input
fieldInput.text = "Type something here!" // Do this to set input
Kotlin

Preview

Idle
Idle

Typing
Typing

Error
Error

Documentation

Attribute for FieldInput

Attribute Name Default Value Description
hint null For set hint of field
focusable true For activate focus
style null For set text appearance of text field
textAllCaps false For activate field text caps
drawableEnd null For put drawable in the right side
inputType text For input type field
textColor null For set color text field
textSize 14sp For set text size field

GitHub