Skip to content

Commit 41ac1c4

Browse files
committed
Styling by @gellermark
1 parent a4f1ca7 commit 41ac1c4

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Float Labeled EditText
44
Android view which uses a EditText and puts the hint on top of the EditText when it is populated with text.
55

66
iOS implementation by [@jverdi](http://www.twitter.com/jverdi): [JVFloatLabeledTextField](https://github.com/jverdi/JVFloatLabeledTextField)
7+
78
Credits for the concept to Matt D. Smith ([@mds](http://www.twitter.com/mds)), and his original design:
89

910
![Matt D. Smith's Design](http://dribbble.s3.amazonaws.com/users/6410/screenshots/1254439/form-animation-_gif_.gif)
@@ -33,7 +34,12 @@ Add the library project (or just copy the files manually) and then insert the vi
3334
Developed By
3435
============
3536

36-
* Henrik Sandström @ [Wrapp](http://www.wrapp.com)
37+
* Henrik Sandström [@heinrisch](https://twitter.com/Heinrisch)
38+
39+
Styled By
40+
=========
41+
42+
* Marcus Gellemark [Dribbble](http://dribbble.com/Gellermark)
3743

3844
License
3945
=======
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- ~ Copyright (c) 2012 Bohemian Wrappsody AB. -->
3-
42
<merge xmlns:android="http://schemas.android.com/apk/res/android"
53
android:layout_width="wrap_content"
64
android:layout_height="wrap_content"
@@ -12,12 +10,12 @@
1210
android:layout_height="wrap_content"
1311
android:layout_width="match_parent"
1412
android:text="Hint"
15-
android:textStyle="bold"/>
13+
android:textSize="9sp"/>
1614

1715
<EditText
1816
android:layout_height="wrap_content"
1917
android:layout_width="match_parent"
20-
android:layout_marginTop="-6dp"
18+
android:layout_marginTop="-7dp"
2119
android:id="@+id/FloatLabeledEditTextEditText"/>
2220

2321
</merge>

floatlabelededittext/src/com/wrapp/floatlabelededittext/FloatLabeledEditText.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44
import android.content.res.TypedArray;
5+
import android.graphics.Color;
56
import android.text.Editable;
67
import android.text.TextWatcher;
78
import android.util.AttributeSet;
@@ -59,6 +60,7 @@ private void initialize() {
5960

6061
hintTextView.setVisibility(View.INVISIBLE);
6162
editText.addTextChangedListener(onTextChanged);
63+
editText.setOnFocusChangeListener(onFocusChanged);
6264
}
6365

6466
private TextWatcher onTextChanged = new TextWatcher() {
@@ -76,6 +78,17 @@ public void afterTextChanged(Editable editable) {
7678
}
7779
};
7880

81+
private OnFocusChangeListener onFocusChanged = new OnFocusChangeListener() {
82+
@Override
83+
public void onFocusChange(View view, boolean gotFocus) {
84+
if (gotFocus) {
85+
ObjectAnimator.ofFloat(hintTextView, "alpha", 0.33f, 1f).start();
86+
} else {
87+
ObjectAnimator.ofFloat(hintTextView, "alpha", 1f, 0.33f).start();
88+
}
89+
}
90+
};
91+
7992
private void setShowHint(final boolean show) {
8093
AnimatorSet animation = null;
8194
if ((hintTextView.getVisibility() == VISIBLE) && !show) {

0 commit comments

Comments
 (0)