Awesome
EditTextView
Android widget combination of ImageView, EditText and TextView based on Material Design guidelines.
Usage
For a working implementation in the sample app, see the app/
folder.
-
Add the dependency in your build.gradle
compile 'com.gregacucnik:edittextview:1.6'
-
Include EditTextView widget in your layout
<com.gregacucnik.EditTextView android:id="@+id/ettExample" android:layout_width="match_parent" android:layout_height="48dp" app:ettIcon="@drawable/icon_normal" app:ettIconEmpty="@drawable/icon_no_text" app:ettIconInEditMode="@drawable/icon_when_typing" app:ettEmptyTexStyle="normal" app:ettShowHint="false" app:ettEmptyText="Add text…" />
3. (Optional - if you want to exit EditMode when you click outside of EditTextView) Implement OnClickListener for EditTextView parent layout and requestFocus.
```
final LinearLayout llContainer = (LinearLayout)findViewById(R.id.llContainer);
llContainer.setClickable(true);
llContainer.setFocusable(true);
llContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
llContainer.requestFocus();
}
});
- (Optional) Implement
EditTextViewListener
to get callbacks foronEditTextViewEditModeStart()
andonEditTextViewEditModeFinish(String text)
.
Customization
Add xmlns:app="http://schemas.android.com/apk/res-auto"
to (root) layout
app:ettIcon
Icon when EditTextView has textapp:ettIconEmpty
Icon when EditTextView is empty (if not set, ettIcon is used, if set)app:ettIconInEditMode
Optional icon when EditTextView is in EditMode (if not set, ettIcon is used, if set)app:ettText
EditTextView textapp:ettEmptyText
Optional hint text to show when ettText is emptyapp:ettEmptyTexStyle
Custom text style for ettEmptyTextapp:ettTextColor
Custom text color when not emptyapp:ettEmptyColor
Custom text color for ettEmptyTextapp:ettSelectAllOnEditMode
Auto-select text when in EditMode (default: true)app:ettShowHint
Show empty hint text when in EditMode (default: true)app:ettMarginTopBottom
Custom top and bottom margin for the whole viewapp:ettIconMarginLeft
Custom left margin for iconapp:ettIconMarginRight
Custom right margin for iconapp:ettTextMarginLeft
Custom left margin for textapp:ettTextMarginRight
Custom right margin for textapp:ettTextSize
Custom text size (min: 12sp)app:ettLocked
Lock or unlock EditTextView (default: false)app:ettMaxLines
Max lines for EditText, if input type textMultiLine (default: 1)android:inputType
Input type for EditText (default: textCapSentences)
License
The MIT License (MIT)
Copyright (c) 2016 Grega Čučnik
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.