protected void init(Context context, AttributeSet attrs, int defStyle) {
        // Load custom attributes
        final int layoutId;
        final CharSequence floatLabelText;
        final int floatLabelTextAppearance;
        final int floatLabelTextColor;
        final float floatLabelTextSize;

        if (attrs == null) {
            layoutId = getDefaultLayoutId();
            isFloatOnFocusEnabled = true;
            floatLabelText = null;
            floatLabelTextAppearance = -1;
            floatLabelTextColor = 0x66000000;
            floatLabelTextSize = getResources().getDimensionPixelSize(R.dimen.flw_defaultLabelTextSize);
        } else {
            final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingLabelWidgetBase, defStyle, 0);

            layoutId = a.getResourceId(R.styleable.FloatingLabelWidgetBase_android_layout, getDefaultLayoutId());
            isFloatOnFocusEnabled = a.getBoolean(R.styleable.FloatingLabelWidgetBase_flw_floatOnFocus, true);
            floatLabelText = a.getText(R.styleable.FloatingLabelWidgetBase_flw_labelText);
            floatLabelTextColor = a.getColor(R.styleable.FloatingLabelWidgetBase_flw_labelTextColor, 0x66000000);
            floatLabelTextAppearance = a.getResourceId(R.styleable.FloatingLabelWidgetBase_flw_labelTextAppearance, -1);
            floatLabelTextSize = a.getDimension(R.styleable.FloatingLabelWidgetBase_flw_labelTextSize, getResources().getDimensionPixelSize(R.dimen.flw_defaultLabelTextSize));

            a.recycle();
        }

        inflateWidgetLayout(context, layoutId);

        getFloatingLabel().setFocusableInTouchMode(false);
        getFloatingLabel().setFocusable(false);

        setLabelAnimator(getDefaultLabelAnimator());
        setLabelText(floatLabelText);
        if (floatLabelTextAppearance != -1) {
            setLabelTextAppearance(getContext(), floatLabelTextAppearance);
        }
        setLabelColor(floatLabelTextColor);
        setLabelTextSize(TypedValue.COMPLEX_UNIT_PX, floatLabelTextSize);

        afterLayoutInflated(context, attrs, defStyle);

        isLaidOut = false;
        getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                isLaidOut = true;
                setInitialWidgetState();
                if (Build.VERSION.SDK_INT >= 16) {
                    getViewTreeObserver().removeOnGlobalLayoutListener(this);
                } else {
                    getViewTreeObserver().removeGlobalOnLayoutListener(this);
                }
            }
        });

        // Mark init as complete to prevent accidentally breaking the view by
        // adding children
        initCompleted = true;
        onInitCompleted();
    }
protected void init ( Context context , AttributeSet attrs , int defStyle ) { final int layoutId ; final CharSequence floatLabelText ; final int floatLabelTextAppearance ; final int floatLabelTextColor ; final float floatLabelTextSize ; if ( attrs == null ) { layoutId = getDefaultLayoutId ( ) ; isFloatOnFocusEnabled = true ; floatLabelText = null ; floatLabelTextAppearance = - 1 ; floatLabelTextColor = 0x66000000 ; floatLabelTextSize = getResources ( ) . getDimensionPixelSize ( R . dimen . flw_defaultLabelTextSize ) ; } else { final TypedArray a = context . obtainStyledAttributes ( attrs , R . styleable . FloatingLabelWidgetBase , defStyle , 0 ) ; layoutId = a . getResourceId ( R . styleable . FloatingLabelWidgetBase_android_layout , getDefaultLayoutId ( ) ) ; isFloatOnFocusEnabled = a . getBoolean ( R . styleable . FloatingLabelWidgetBase_flw_floatOnFocus , true ) ; floatLabelText = a . getText ( R . styleable . FloatingLabelWidgetBase_flw_labelText ) ; floatLabelTextColor = a . getColor ( R . styleable . FloatingLabelWidgetBase_flw_labelTextColor , 0x66000000 ) ; floatLabelTextAppearance = a . getResourceId ( R . styleable . FloatingLabelWidgetBase_flw_labelTextAppearance , - 1 ) ; floatLabelTextSize = a . getDimension ( R . styleable . FloatingLabelWidgetBase_flw_labelTextSize , getResources ( ) . getDimensionPixelSize ( R . dimen . flw_defaultLabelTextSize ) ) ; a . recycle ( ) ; } inflateWidgetLayout ( context , layoutId ) ; getFloatingLabel ( ) . setFocusableInTouchMode ( false ) ; getFloatingLabel ( ) . setFocusable ( false ) ; setLabelAnimator ( getDefaultLabelAnimator ( ) ) ; setLabelText ( floatLabelText ) ; if ( floatLabelTextAppearance != - 1 ) { setLabelTextAppearance ( getContext ( ) , floatLabelTextAppearance ) ; } setLabelColor ( floatLabelTextColor ) ; setLabelTextSize ( TypedValue . COMPLEX_UNIT_PX , floatLabelTextSize ) ; afterLayoutInflated ( context , attrs , defStyle ) ; isLaidOut = false ; getViewTreeObserver ( ) . addOnGlobalLayoutListener ( new ViewTreeObserver . OnGlobalLayoutListener ( ) { @ Override public void onGlobalLayout ( ) { isLaidOut = true ; setInitialWidgetState ( ) ; if ( Build . VERSION . SDK_INT >= 16 ) { getViewTreeObserver ( ) . removeOnGlobalLayoutListener ( this ) ; } else { getViewTreeObserver ( ) . removeGlobalOnLayoutListener ( this ) ; } } } ) ; initCompleted = true ; onInitCompleted ( ) ; }
Initialise the widget: read attributes, inflate layout and set the basic properties

@param context
@param attrs
@param defStyle