public static AutofitHelper create(TextView view, AttributeSet attrs, int defStyle) { AutofitHelper helper = new AutofitHelper(view); boolean sizeToFit = true; if (attrs != null) { Context context = view.getContext(); int minTextSize = (int) helper.getMinTextSize(); float precision = helper.getPrecision(); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.Custom_TextView, defStyle, 0); sizeToFit = ta.getBoolean(R.styleable.Custom_TextView_sizeFit, sizeToFit); minTextSize = ta.getDimensionPixelSize(R.styleable.Custom_TextView_minSize, minTextSize); precision = ta.getFloat(R.styleable.Custom_TextView_precisionText, precision); ta.recycle(); helper.setMinTextSize(TypedValue.COMPLEX_UNIT_PX, minTextSize).setPrecision(precision); } helper.setEnabled(sizeToFit); return helper; }