Last active
August 29, 2015 14:16
-
-
Save tonespy/9e3689449d13549da6ca to your computer and use it in GitHub Desktop.
Revisions
-
Abubakar Oladeji revised this gist
May 22, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,4 +2,6 @@ I have seen different FloatLabel libraries. But, they all look kind of not follo set the attrs.xml Create the layouts using the "Merge" Tag Then create the class for the view Extending Linear Layout -
Abubakar Oladeji revised this gist
Feb 26, 2015 . 3 changed files with 56 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ <!--FloatLabelAutoCompleteTextView XML Layout --> <?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:id="@+id/textview_float" android:layout_height="wrap_content" android:layout_width="wrap_content" android:visibility="invisible" android:paddingLeft="5dp" android:paddingStart="5dp" android:focusable="false" android:textStyle="bold"/> <AutoCompleteTextView android:id="@+id/autoview_main" android:visibility="visible" android:layout_height="wrap_content" android:layout_width="match_parent"/> </merge> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ <!--EditText FloatLabel --> <?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:id="@+id/textview_float" android:layout_height="wrap_content" android:layout_width="wrap_content" android:visibility="invisible" android:paddingLeft="5dp" android:paddingStart="5dp" android:focusable="false" android:textStyle="bold"/> <AutoCompleteTextView android:id="@+id/textview_main" android:visibility="visible" android:layout_height="wrap_content" android:layout_width="match_parent" android:drawableRight="@android:drawable/arrow_down_float"/> </merge> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ <!-- Spinner Float --> <?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:id="@+id/spinnerTextview_float" android:layout_height="wrap_content" android:layout_width="wrap_content" android:visibility="invisible" android:paddingLeft="5dp" android:paddingStart="5dp" android:focusable="false" android:textStyle="bold"/> <Spinner android:id="@+id/spinnerview_main" android:visibility="visible" android:layout_height="wrap_content" android:layout_width="match_parent" style="@style/Base.Widget.AppCompat.Spinner"/> </merge> -
Abubakar Oladeji created this gist
Feb 26, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,273 @@ import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.Typeface; import android.text.Editable; import android.text.TextWatcher; import android.text.method.KeyListener; import android.util.AttributeSet; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.LinearLayout; import android.widget.TextView; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.Animator.AnimatorListener; import com.nineoldandroids.animation.AnimatorSet; import com.nineoldandroids.animation.ArgbEvaluator; import com.nineoldandroids.animation.ObjectAnimator; import com.nineoldandroids.animation.ValueAnimator; public class FloatLabelAutoCompleteTextView extends LinearLayout { private static final String TAG = "FloatLabelTextView"; private static long ANIMATION_DURATION = 400; private static int HINT_DEFAULT_COLOR = 0xFF006363; private static final int HINT_DEFAULT_COLOR_DISABLED = 0xFFCCCCCC; private static int HINT_DEFAULT_SIZE = 13; private TextView mHintView; private AutoCompleteTextView mEditText; private int mHintColor; private AnimatorSet mEntranceAnimation = null; private AnimatorSet mExitAnimation = null; private ValueAnimator mAddColorAnimation = null; private ValueAnimator mRemoveColorAnimation = null; public FloatLabelAutoCompleteTextView(Context context) { this(context, null); } public FloatLabelAutoCompleteTextView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LinearLayout.VERTICAL); setGravity(Gravity.LEFT); LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.float_label_autocompletetextview, this, true); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelTextView, 0, 0); String hint = array .getString(R.styleable.FloatLabelTextView_editText_hint); mHintColor = array.getColor( R.styleable.FloatLabelTextView_editText_color, HINT_DEFAULT_COLOR); float size = array .getDimension(R.styleable.FloatLabelTextView_editText_size, HINT_DEFAULT_SIZE); array.recycle(); mHintView = (TextView) findViewById(R.id.textview_float); mEditText = (AutoCompleteTextView) findViewById(R.id.autoview_main); mHintView.setTextColor(HINT_DEFAULT_COLOR_DISABLED); mHintView.setText(hint); mEditText.setHint(hint); mHintView.setTextSize(size); mEditText.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { getRemoveColorAnimation().start(); } else { getAddColorAnimation().start(); } } }); mEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.length() > 0) { if (mHintView.getVisibility() == View.INVISIBLE) { getEntranceAnimation().start(); } } else { getExitAnimation().start(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); } public void addTextChangedListener(TextWatcher watcher) { mEditText.addTextChangedListener(watcher); } protected ValueAnimator getAddColorAnimation() { if (mAddColorAnimation == null) { mAddColorAnimation = ObjectAnimator.ofInt(mHintView, "textColor", HINT_DEFAULT_COLOR_DISABLED, mHintColor); mAddColorAnimation.setEvaluator(new ArgbEvaluator()); mAddColorAnimation.setDuration(ANIMATION_DURATION); } return mAddColorAnimation; } protected ValueAnimator getRemoveColorAnimation() { if (mRemoveColorAnimation == null) { mRemoveColorAnimation = ObjectAnimator.ofInt(mHintView, "textColor", mHintColor, HINT_DEFAULT_COLOR_DISABLED); mRemoveColorAnimation.setEvaluator(new ArgbEvaluator()); mRemoveColorAnimation.setDuration(ANIMATION_DURATION); } return mRemoveColorAnimation; } protected AnimatorSet getExitAnimation() { if (mExitAnimation == null) { mExitAnimation = new AnimatorSet(); mExitAnimation.playTogether( ObjectAnimator.ofFloat(mHintView, "translationY", 0, 30), ObjectAnimator.ofFloat(mHintView, "alpha", 1, 0)); mExitAnimation.setDuration(ANIMATION_DURATION); mExitAnimation.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mHintView.setVisibility(View.INVISIBLE); } @Override public void onAnimationCancel(Animator animation) { } }); } return mExitAnimation; } @Override public void setOnClickListener(OnClickListener l) { mEditText.setOnClickListener(l); super.setOnClickListener(l); } @Override public void setTag(Object tag) { mEditText.setTag(tag); super.setTag(tag); } @Override public void setTag(int key, Object tag) { mEditText.setTag(key, tag); super.setTag(key, tag); } protected AnimatorSet getEntranceAnimation() { if (mEntranceAnimation == null) { mEntranceAnimation = new AnimatorSet(); mEntranceAnimation.playTogether( ObjectAnimator.ofFloat(mHintView, "translationY", 30, 0), ObjectAnimator.ofFloat(mHintView, "alpha", 0, 1)); mEntranceAnimation.setDuration(ANIMATION_DURATION); mEntranceAnimation.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { mHintView.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { } @Override public void onAnimationCancel(Animator animation) { } }); } return mEntranceAnimation; } public void setAnimationDuration(long duration) { ANIMATION_DURATION = duration; } public void setHint(String text) { mHintView.setText(text); mEditText.setHint(text); } public void setKeyListener(KeyListener input) { mEditText.setKeyListener(input); } public void setText(CharSequence text) { mEditText.setText(text); } public void setText(String text) { mEditText.setText(text); } public void setTextColor(ColorStateList colors) { mHintView.setTextColor(colors); } public void setTextColor(int color) { mHintView.setTextColor(color); } public Editable getText() { return mEditText.getText(); } public void setTextSize(float size) { mHintView.setTextSize(size); } public void setTextSize(int unit, float size) { mHintView.setTextSize(unit, size); } public void setTypeface(Typeface tf, int style) { mHintView.setTypeface(tf, style); } public void setTypeface(Typeface tf) { mHintView.setTypeface(tf); } public void setAdapter(ArrayAdapter<String> adapter){ mEditText.setAdapter(adapter); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,271 @@ import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.Typeface; import android.text.Editable; import android.text.TextWatcher; import android.text.method.KeyListener; import android.util.AttributeSet; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.ListPopupWindow; import android.widget.TextView; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.Animator.AnimatorListener; import com.nineoldandroids.animation.AnimatorSet; import com.nineoldandroids.animation.ArgbEvaluator; import com.nineoldandroids.animation.ObjectAnimator; import com.nineoldandroids.animation.ValueAnimator; public class FloatLabelTextView extends LinearLayout { private static final String TAG = "FloatLabelTextView"; private static long ANIMATION_DURATION = 400; private static int HINT_DEFAULT_COLOR = 0xFF006363; private static final int HINT_DEFAULT_COLOR_DISABLED = 0xFFCCCCCC; private static int HINT_DEFAULT_SIZE = 13; private TextView mHintView; private EditText mEditText; private int mHintColor; private AnimatorSet mEntranceAnimation = null; private AnimatorSet mExitAnimation = null; private ValueAnimator mAddColorAnimation = null; private ValueAnimator mRemoveColorAnimation = null; private ListPopupWindow mPopup; public FloatLabelTextView(Context context) { this(context, null); } public FloatLabelTextView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LinearLayout.VERTICAL); setGravity(Gravity.LEFT); LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.float_label_textview, this, true); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelTextView, 0, 0); String hint = array .getString(R.styleable.FloatLabelTextView_editText_hint); mHintColor = array.getColor( R.styleable.FloatLabelTextView_editText_color, HINT_DEFAULT_COLOR); float size = array .getDimension(R.styleable.FloatLabelTextView_editText_size, HINT_DEFAULT_SIZE); array.recycle(); mHintView = (TextView) findViewById(R.id.textview_float); mEditText = (EditText) findViewById(R.id.textview_main); mHintView.setTextColor(HINT_DEFAULT_COLOR_DISABLED); mHintView.setText(hint); mEditText.setHint(hint); mHintView.setTextSize(size); mEditText.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { getRemoveColorAnimation().start(); } else { getAddColorAnimation().start(); } } }); mEditText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.length() > 0) { if (mHintView.getVisibility() == View.INVISIBLE) { getEntranceAnimation().start(); } } else { getExitAnimation().start(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); } public void addTextChangedListener(TextWatcher watcher) { mEditText.addTextChangedListener(watcher); } protected ValueAnimator getAddColorAnimation() { if (mAddColorAnimation == null) { mAddColorAnimation = ObjectAnimator.ofInt(mHintView, "textColor", HINT_DEFAULT_COLOR_DISABLED, mHintColor); mAddColorAnimation.setEvaluator(new ArgbEvaluator()); mAddColorAnimation.setDuration(ANIMATION_DURATION); } return mAddColorAnimation; } protected ValueAnimator getRemoveColorAnimation() { if (mRemoveColorAnimation == null) { mRemoveColorAnimation = ObjectAnimator.ofInt(mHintView, "textColor", mHintColor, HINT_DEFAULT_COLOR_DISABLED); mRemoveColorAnimation.setEvaluator(new ArgbEvaluator()); mRemoveColorAnimation.setDuration(ANIMATION_DURATION); } return mRemoveColorAnimation; } protected AnimatorSet getExitAnimation() { if (mExitAnimation == null) { mExitAnimation = new AnimatorSet(); mExitAnimation.playTogether( ObjectAnimator.ofFloat(mHintView, "translationY", 0, 30), ObjectAnimator.ofFloat(mHintView, "alpha", 1, 0)); mExitAnimation.setDuration(ANIMATION_DURATION); mExitAnimation.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mHintView.setVisibility(View.INVISIBLE); } @Override public void onAnimationCancel(Animator animation) { } }); } return mExitAnimation; } @Override public void setOnClickListener(OnClickListener l) { mEditText.setOnClickListener(l); super.setOnClickListener(l); } @Override public void setTag(Object tag) { mEditText.setTag(tag); super.setTag(tag); } @Override public void setTag(int key, Object tag) { mEditText.setTag(key, tag); super.setTag(key, tag); } protected AnimatorSet getEntranceAnimation() { if (mEntranceAnimation == null) { mEntranceAnimation = new AnimatorSet(); mEntranceAnimation.playTogether( ObjectAnimator.ofFloat(mHintView, "translationY", 30, 0), ObjectAnimator.ofFloat(mHintView, "alpha", 0, 1)); mEntranceAnimation.setDuration(ANIMATION_DURATION); mEntranceAnimation.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { mHintView.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { } @Override public void onAnimationCancel(Animator animation) { } }); } return mEntranceAnimation; } public void setAnimationDuration(long duration) { ANIMATION_DURATION = duration; } public void setHint(String text) { mHintView.setText(text); mEditText.setHint(text); } public void setKeyListener(KeyListener input) { mEditText.setKeyListener(input); } public void setText(CharSequence text) { mEditText.setText(text); } public void setText(String text) { mEditText.setText(text); } public void setTextColor(ColorStateList colors) { mHintView.setTextColor(colors); } public void setTextColor(int color) { mHintView.setTextColor(color); } public Editable getText() { return mEditText.getText(); } public void setTextSize(float size) { mHintView.setTextSize(size); } public void setTextSize(int unit, float size) { mHintView.setTextSize(unit, size); } public void setTypeface(Typeface tf, int style) { mHintView.setTypeface(tf, style); } public void setTypeface(Typeface tf) { mHintView.setTypeface(tf); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,241 @@ import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.Typeface; import android.util.AttributeSet; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.LinearLayout; import android.widget.Spinner; import android.widget.TextView; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.Animator.AnimatorListener; import com.nineoldandroids.animation.AnimatorSet; import com.nineoldandroids.animation.ArgbEvaluator; import com.nineoldandroids.animation.ObjectAnimator; import com.nineoldandroids.animation.ValueAnimator; /** * Created by mac on 2/26/15. */ public class FloatLabelSpinnerView extends LinearLayout { private static final String TAG = "FloatSpinnerView"; private static long ANIMATION_DURATION = 400; private static int HINT_DEFAULT_COLOR = 0xFF006363; private static final int HINT_DEFAULT_COLOR_DISABLED = 0xFFCCCCCC; private static int HINT_DEFAULT_SIZE = 13; private TextView mHintView; private Spinner mSpinner; private int mHintColor; private AnimatorSet mEntranceAnimation = null; private AnimatorSet mExitAnimation = null; private ValueAnimator mAddColorAnimation = null; private ValueAnimator mRemoveColorAnimation = null; public FloatLabelSpinnerView(Context context) { super(context); } public FloatLabelSpinnerView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LinearLayout.VERTICAL); setGravity(Gravity.LEFT); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.float_label_spinnerview, this, true); TypedArray array = context.obtainStyledAttributes(attrs,R.styleable.FloatLabelTextView, 0, 0); String hint = array.getString(R.styleable.FloatLabelTextView_editText_hint); mHintColor = array.getColor(R.styleable.FloatLabelTextView_editText_color, HINT_DEFAULT_COLOR); float size = array.getDimension(R.styleable.FloatLabelTextView_editText_size, HINT_DEFAULT_SIZE); array.recycle(); mHintView = (TextView) findViewById(R.id.spinnerTextview_float); mSpinner = (Spinner) findViewById(R.id.spinnerview_main); mHintView.setTextColor(HINT_DEFAULT_COLOR_DISABLED); mHintView.setText(hint); mHintView.setTextSize(size); mSpinner.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { getRemoveColorAnimation().start(); } else { getAddColorAnimation().start(); } } }); mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position > 0) { if (mHintView.getVisibility() == View.INVISIBLE) { getEntranceAnimation().start(); } } else { getExitAnimation().start(); } } @Override public void onNothingSelected(AdapterView<?> parent) { getExitAnimation().start(); } }); } protected ValueAnimator getAddColorAnimation() { if (mAddColorAnimation == null){ mAddColorAnimation = ObjectAnimator.ofInt(mHintView, "textColor", HINT_DEFAULT_COLOR_DISABLED, mHintColor); mAddColorAnimation.setEvaluator(new ArgbEvaluator()); mAddColorAnimation.setDuration(ANIMATION_DURATION); } return mAddColorAnimation; } protected ValueAnimator getRemoveColorAnimation(){ if (mRemoveColorAnimation == null) { mRemoveColorAnimation = ObjectAnimator.ofInt(mHintView, "textColor", mHintColor, HINT_DEFAULT_COLOR_DISABLED); mRemoveColorAnimation.setEvaluator(new ArgbEvaluator()); mRemoveColorAnimation.setDuration(ANIMATION_DURATION); } return mRemoveColorAnimation; } protected AnimatorSet getExitAnimation() { if (mExitAnimation == null) { mExitAnimation = new AnimatorSet(); mExitAnimation.playTogether( ObjectAnimator.ofFloat(mHintView, "translationY", 0, 30), ObjectAnimator.ofFloat(mHintView, "alpha", 1, 0)); mExitAnimation.setDuration(ANIMATION_DURATION); mExitAnimation.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mHintView.setVisibility(View.INVISIBLE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); } return mExitAnimation; } @Override public void setOnTouchListener(OnTouchListener l) { mSpinner.setOnTouchListener(l); super.setOnTouchListener(l); } @Override public void setTag(Object tag) { mSpinner.setTag(tag); super.setTag(tag); } @Override public void setTag(int key, Object tag) { mSpinner.setTag(key, tag); super.setTag(key, tag); } protected AnimatorSet getEntranceAnimation(){ if (mEntranceAnimation == null) { mEntranceAnimation = new AnimatorSet(); mEntranceAnimation.playTogether( ObjectAnimator.ofFloat(mHintView, "translationY", 30, 0), ObjectAnimator.ofFloat(mHintView, "alpha", 0, 1)); mEntranceAnimation.setDuration(ANIMATION_DURATION); mEntranceAnimation.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { mHintView.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); } return mEntranceAnimation; } public void setAnimationDuration(long duration) { ANIMATION_DURATION = duration; } public void setHint(String text) { mHintView.setText(text); } public void setTextSize(float size) { mHintView.setTextSize(size); } public void setTextSize(int unit, float size) { mHintView.setTextSize(unit, size); } public void setTypeface(Typeface tf, int style) { mHintView.setTypeface(tf, style); } public void setTypeface(Typeface tf) { mHintView.setTypeface(tf); } public void setTextColor(ColorStateList colors) { mHintView.setTextColor(colors); } public void setTextColor(int color) { mHintView.setTextColor(color); } public void setAdatper(ArrayAdapter<String> adapter){ mSpinner.setAdapter(adapter); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ //Adapter for spinner and autocompletetextview final String[] COUNTRIES = new String[] { "Belgium", "France", "Italy", "Germany", "Spain" }; ArrayAdapter<String> adapters = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES); //To test Spinner //XML For Spinner //====================================== /*<com.testapp.FloatLabelSpinnerView * android:id="@+id/mSpinns" * android:layout_width="match_parent" * android:layout_height="80dp" * app:editText_color="@color/colorPrimary" * app:editText_size="5sp"//Hint Text Size * app:editText_hint="Identity"> */ mSpinns = (FloatLabelSpinnerView) findViewById(R.id.mSpinns); mSpinns.setAdatper(adapters); //===================================================== //To set autoCompleteTextView /*<deliveryscience.testapp.FloatLabelAutoCompleteTextView android:id="@+id/floatText" android:layout_width="match_parent" android:layout_height="80dp" android:textSize="17sp" android:hint="Password" app:editText_color="@color/colorPrimary" app:editText_size="5sp" app:editText_hint="Password"/> */ FloatLabelAutoCompleteTextView floatingLabelAutoCompleteTextView = (FloatLabelAutoCompleteTextView) findViewById(R.id.floatText); floatingLabelAutoCompleteTextView.setAdapter(adapters); //Implementing EditText /*<deliveryscience.testapp.FloatLabelTextView android:layout_width="match_parent" android:layout_height="80dp" android:textSize="17sp" android:hint="Password" app:editText_color="@color/colorPrimary" app:editText_size="5sp" app:editText_hint="Password"/> */ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="FloatLabelTextView"> <attr name="editText_hint" format="string"/> <attr name="editText_color" format="color"/> <attr name="editText_size" format="dimension"/> </declare-styleable> </resources> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ I have seen different FloatLabel libraries. But, they all look kind of not following material design rule for looks. Monitoring the Accents, colorControlNormal and all and kinda hard to fix. So I decided to do mine for EditText, Spinner and AutoCompleteTextView and buzz me if you need for any other android.view.widget. After reading someone EditText library I decided to do mine too set the attrs.xml Then create the class for the view Extending Linear Layout