@@ -0,0 +1,2891 @@
+package me.grantland.widget;%0A%0Aimport android.content.Context;%0Aimport android.content.res.TypedArray;%0Aimport android.util.AttributeSet;%0Aimport android.util.TypedValue;%0Aimport android.view.View;%0Aimport android.view.ViewGroup;%0Aimport android.widget.FrameLayout;%0Aimport android.widget.TextView;%0A%0Aimport java.util.WeakHashMap;%0A%0Aimport me.grantland.autofittextview.R;%0A%0A/**%0A * A ViewGroup that re-sizes the text of it's children to be no larger than the width of the view.%0A *%0A * Created by Grantland Chew on 6/21/14.%0A */%0Apublic class AutofitLayout extends FrameLayout %7B%0A%0A    private boolean mEnabled;%0A    private float mMinTextSize;%0A    private float mPrecision;%0A    private WeakHashMap%3CView, AutofitHelper%3E mHelpers = new WeakHashMap%3CView, AutofitHelper%3E();%0A%0A    public AutofitLayout(Context context) %7B%0A        super(context);%0A        init(context, null, 0);%0A    %7D%0A%0A    public AutofitLayout(Context context, AttributeSet attrs) %7B%0A        super(context, attrs);%0A        init(context, attrs, 0);%0A    %7D%0A%0A    public AutofitLayout(Context context, AttributeSet attrs, int defStyle) %7B%0A        super(context, attrs, defStyle);%0A        init(context, attrs, defStyle);%0A    %7D%0A%0A    private void init(Context context, AttributeSet attrs, int defStyle) %7B%0A        boolean sizeToFit = true;%0A        int minTextSize = -1;%0A        float precision = -1;%0A%0A        if (attrs != null) %7B%0A            TypedArray ta = context.obtainStyledAttributes(%0A                    attrs,%0A                    R.styleable.AutofitTextView,%0A                    defStyle,%0A                    0);%0A            sizeToFit = ta.getBoolean(R.styleable.AutofitTextView_sizeToFit, sizeToFit);%0A            minTextSize = ta.getDimensionPixelSize(R.styleable.AutofitTextView_minTextSize,%0A                    minTextSize);%0A            precision = ta.getFloat(R.styleable.AutofitTextView_precision, precision);%0A            ta.recycle();%0A        %7D%0A%0A        mEnabled = sizeToFit;%0A        mMinTextSize = minTextSize;%0A        mPrecision = precision;%0A    %7D%0A%0A    @Override%0A    public void addView(View child, int index, ViewGroup.LayoutParams params) %7B%0A        super.addView(child, index, params);%0A        TextView textView = (TextView) child;%0A        AutofitHelper helper = AutofitHelper.create(textView)%0A                .setEnabled(mEnabled);%0A        if (mPrecision %3E 0) %7B%0A            helper.setPrecision(mPrecision);%0A        %7D%0A        if (mMinTextSize %3E 0) %7B%0A            helper.setMinTextSize(TypedValue.COMPLEX_UNIT_PX, mMinTextSize);%0A        %7D%0A        mHelpers.put(textView, helper);%0A    %7D%0A%0A    /**%0A     * @return the AutofitHelper for this child View.%0A     */%0A    public AutofitHelper getAutofitHelper(TextView textView) %7B%0A        return mHelpers.get(textView);%0A    %7D%0A%0A    /**%0A     * @return the AutofitHelper for this child View.%0A     */%0A    public AutofitHelper getAutofitHelper(int index) %7B%0A        return mHelpers.get(getChildAt(index));%0A    %7D%0A%7D%0A

Add AutofitLayout