mhelder / clearable-edittext

Simple custom view for clearable EditText.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

clearable-edittext

Build Status

Simple custom view for clearable EditText.

Function

Usage

  • Add a icon in the right of EditText and its subclass:
    • AutoCompleteTextView
    • TextInputEditText
  • Clear texts when the icon is touched
  • Hide icon when EditText not focused
  • You can define your own icon drawable

Gradle Dependency

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

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

Step 2. Add the dependency

dependencies {
  compile 'com.github.Cielsk:clearable-edittext:0.0.3'
}

The latest version is shown on JitPack badge.

Usage

By default, the clear icon is a black material design icon called 'content/ic_clear'.

Default Clearable EditText:

<com.cielyang.android.clearableedittext.ClearableEditText
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  />

Screenshot of demo: Default Icon

And you can define your own icon drawable by assigning drawable resource to app:clearIconDrawable:

Custom Clearable EditText:

<com.cielyang.android.clearableedittext.ClearableEditText
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  app:clearIconDrawable="@drawable/ic_clear_grey_500_24dp"
  app:clearIconDrawWhenFocused="false"
  />

Screenshot of demo: Custom Icon

You can use subclasses in the same way(just change the class name).

About

Simple custom view for clearable EditText.


Languages

Language:Java 100.0%