IconEditText for Android

IconEditText provides a reusable view for displaying an ImageView with an EditText for Android 4.0 +.

Usage

Using the IconEditText is easy enough, just clone the repo and add it to your project as a Library.

After adding the library, you can add an IconEditText like so:

XML

<!-- Note the declaration of the `widget` namespace. -->
<LinearLayout 
  ...
  xmlns:widget="http://schemas.android.com/apk/res-auto">

  <com.kylewbanks.android.iconedittext.IconEditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      widget:isPassword="false"
      widget:hint="@string/username"
      widget:iconSrc="@drawable/username_icon" />

</LinearLayout>

Options

The IconEditText currently supports the following properties:

Java

From Java, you can reference the IconEditText like any other view. For example, from an Activity:

IconEditText iconEditText = (IconEditText) findViewById(...);

You can access the underlying EditText and ImageView like so:

EditText editText = iconEditText.getEditText();
ImageView imageView = iconEditText.getImageView();

There is also a convenience method for accessing the EditText's Editable:

Editable editable = iconEditText.getText();

Author

Kyle Banks

License

The MIT License (MIT)

Copyright (c) 2015 Kyle Banks

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.