Example usage for android.content.res TypedArray recycle

List of usage examples for android.content.res TypedArray recycle

Introduction

In this page you can find the example usage for android.content.res TypedArray recycle.

Prototype

public void recycle() 

Source Link

Document

Recycles the TypedArray, to be re-used by a later caller.

Usage

From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java

private static Keyframe loadKeyframe(Context context, Resources res, Theme theme, AttributeSet attrs,
        int valueType, XmlPullParser parser) throws XmlPullParserException, IOException {

    TypedArray a = TypedArrayUtils.obtainAttributes(res, theme, attrs, AndroidResources.STYLEABLE_KEYFRAME);

    Keyframe keyframe = null;//from   www  .  j av a2s. c  om

    float fraction = TypedArrayUtils.getNamedFloat(a, parser, "fraction",
            AndroidResources.STYLEABLE_KEYFRAME_FRACTION, -1);

    TypedValue keyframeValue = TypedArrayUtils.peekNamedValue(a, parser, "value",
            AndroidResources.STYLEABLE_KEYFRAME_VALUE);
    boolean hasValue = (keyframeValue != null);
    if (valueType == VALUE_TYPE_UNDEFINED) {
        // When no value type is provided, check whether it's a color type first.
        // If not, fall back to default value type (i.e. float type).
        if (hasValue && isColorType(keyframeValue.type)) {
            valueType = VALUE_TYPE_COLOR;
        } else {
            valueType = VALUE_TYPE_FLOAT;
        }
    }

    if (hasValue) {
        switch (valueType) {
        case VALUE_TYPE_FLOAT:
            float value = TypedArrayUtils.getNamedFloat(a, parser, "value",
                    AndroidResources.STYLEABLE_KEYFRAME_VALUE, 0);
            keyframe = Keyframe.ofFloat(fraction, value);
            break;
        case VALUE_TYPE_COLOR:
        case VALUE_TYPE_INT:
            int intValue = TypedArrayUtils.getNamedInt(a, parser, "value",
                    AndroidResources.STYLEABLE_KEYFRAME_VALUE, 0);
            keyframe = Keyframe.ofInt(fraction, intValue);
            break;
        }
    } else {
        keyframe = (valueType == VALUE_TYPE_FLOAT) ? Keyframe.ofFloat(fraction) : Keyframe.ofInt(fraction);
    }

    final int resID = TypedArrayUtils.getNamedResourceId(a, parser, "interpolator",
            AndroidResources.STYLEABLE_KEYFRAME_INTERPOLATOR, 0);
    if (resID > 0) {
        final Interpolator interpolator = AnimationUtilsCompat.loadInterpolator(context, resID);
        keyframe.setInterpolator(interpolator);
    }
    a.recycle();

    return keyframe;
}

From source file:com.todddavies.components.progressbar.ProgressWheel.java

/**
 * Parse the attributes passed to the view from the XML
 *
 * @param a the attributes to parse//from  ww  w .j  av a  2 s. co  m
 */
private void parseAttributes(TypedArray a) {
    barWidth = (int) a.getDimension(R.styleable.ProgressWheel_barWidth, barWidth);

    rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_rimWidth, rimWidth);

    spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_spinSpeed, spinSpeed);

    delayMillis = a.getInteger(R.styleable.ProgressWheel_delayMillis, delayMillis);
    if (delayMillis < 0) {
        delayMillis = 0;
    }

    barColor = a.getColor(R.styleable.ProgressWheel_barColor, barColor);

    barLength = (int) a.getDimension(R.styleable.ProgressWheel_barLength, barLength);

    textSize = (int) a.getDimension(R.styleable.ProgressWheel_textSize, textSize);

    textColor = (int) a.getColor(R.styleable.ProgressWheel_textColor, textColor);

    //if the text is empty , so ignore it
    if (a.hasValue(R.styleable.ProgressWheel_text)) {
        setText(a.getString(R.styleable.ProgressWheel_text));
    }

    rimColor = (int) a.getColor(R.styleable.ProgressWheel_rimColor, rimColor);

    circleColor = (int) a.getColor(R.styleable.ProgressWheel_circleColor, circleColor);

    contourColor = a.getColor(R.styleable.ProgressWheel_contourColor, contourColor);
    contourSize = a.getDimension(R.styleable.ProgressWheel_contourSize, contourSize);

    // Recycle
    a.recycle();
}

From source file:android_hddl_framework.viewpagerindicator.CirclePageIndicator.java

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from www  .  j ava 2  s  .  c  o m

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultExtraSpacing = res.getDimension(R.dimen.default_circle_indicator_extra_spacing);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);
    mExtraSpacing = a.getDimension(R.styleable.CirclePageIndicator_extraSpacing, defaultExtraSpacing);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.scoreflex.ScoreflexView.java

/**
 * The constructor of the view.//w  w  w. j a v  a2 s  .c om
 * @param activity The activity holding the view.
 * @param attrs
 * @param defStyle
 */
@SuppressWarnings("deprecation")
public ScoreflexView(Activity activity, AttributeSet attrs, int defStyle) {
    super(activity, attrs, defStyle);

    // Keep a reference on the activity
    mParentActivity = activity;

    // Default layout params
    if (null == getLayoutParams()) {
        setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                Scoreflex.getDensityIndependantPixel(R.dimen.scoreflex_panel_height)));
    }

    // Set our background color
    setBackgroundColor(getContext().getResources().getColor(R.color.scoreflex_background_color));

    // Create the top bar
    View topBar = new View(getContext());
    topBar.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            getResources().getDimensionPixelSize(R.dimen.scoreflex_topbar_height), Gravity.TOP));
    topBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.scoreflex_gradient_background));
    addView(topBar);

    // Create the retry button
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mErrorLayout = (ViewGroup) inflater.inflate(R.layout.scoreflex_error_layout, null);
    if (mErrorLayout != null) {

        // Configure refresh button
        Button refreshButton = (Button) mErrorLayout.findViewById(R.id.scoreflex_retry_button);
        if (null != refreshButton) {
            refreshButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    if (null == Scoreflex.getPlayerId()) {
                        setUserInterfaceState(new LoadingState());
                        loadUrlAfterLoggedIn(mInitialResource, mInitialRequestParams);
                    } else if (null == mWebView.getUrl()) {
                        setResource(mInitialResource);
                    } else {
                        mWebView.reload();
                    }
                }
            });
        }

        // Configure cancel button
        Button cancelButton = (Button) mErrorLayout.findViewById(R.id.scoreflex_cancel_button);
        if (null != cancelButton) {
            cancelButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    close();
                }
            });
        }

        // Get hold of the message view
        mMessageView = (TextView) mErrorLayout.findViewById(R.id.scoreflex_error_message_view);
        addView(mErrorLayout);

    }

    // Create the close button
    mCloseButton = new ImageButton(getContext());
    Drawable closeButtonDrawable = getResources().getDrawable(R.drawable.scoreflex_close_button);
    int closeButtonMargin = (int) ((getResources().getDimensionPixelSize(R.dimen.scoreflex_topbar_height)
            - closeButtonDrawable.getIntrinsicHeight()) / 2.0f);
    FrameLayout.LayoutParams closeButtonLayoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.TOP | Gravity.RIGHT);
    closeButtonLayoutParams.setMargins(0, closeButtonMargin, closeButtonMargin, 0);
    mCloseButton.setLayoutParams(closeButtonLayoutParams);
    mCloseButton.setImageDrawable(closeButtonDrawable);
    mCloseButton.setBackgroundDrawable(null);
    mCloseButton.setPadding(0, 0, 0, 0);
    mCloseButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            close();
        }
    });
    addView(mCloseButton);

    // Create the web view
    mWebView = new WebView(mParentActivity);
    mWebView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    // mWebView.setBackgroundColor(Color.RED);
    mWebView.setWebViewClient(new ScoreflexWebViewClient());
    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public boolean onConsoleMessage(ConsoleMessage cm) {
            Log.d("Scoreflex", "javascript Error: "
                    + String.format("%s @ %d: %s", cm.message(), cm.lineNumber(), cm.sourceId()));
            return true;
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg) {
            // mtbActivity.mUploadMessage = uploadMsg;
            mUploadMessage = uploadMsg;

            String fileName = "picture.jpg";
            ContentValues values = new ContentValues();
            values.put(MediaStore.Images.Media.TITLE, fileName);
            // mOutputFileUri = mParentActivity.getContentResolver().insert(
            // MediaStore.Images.Media.DATA, values);
            final List<Intent> cameraIntents = new ArrayList<Intent>();
            final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            final PackageManager packageManager = mParentActivity.getPackageManager();
            final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
            for (ResolveInfo res : listCam) {
                final String packageName = res.activityInfo.packageName;
                final Intent intent = new Intent(captureIntent);
                intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
                intent.setPackage(packageName);
                cameraIntents.add(intent);
            }

            // Filesystem.
            final Intent galleryIntent = new Intent();
            galleryIntent.setType("image/*");
            galleryIntent.setAction(Intent.ACTION_GET_CONTENT);

            // Chooser of filesystem options.
            final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source please");

            // Add the camera options.
            chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {}));

            mParentActivity.startActivityForResult(chooserIntent, Scoreflex.FILECHOOSER_RESULTCODE);
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
            openFileChooser(uploadMsg);
        }

        public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
            openFileChooser(uploadMsg);
        }
    });
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    mWebView.getSettings().setDatabasePath(
            getContext().getFilesDir().getPath() + "/data/" + getContext().getPackageName() + "/databases/");
    addView(mWebView);

    TypedArray a = mParentActivity.obtainStyledAttributes(attrs, R.styleable.ScoreflexView, defStyle, 0);
    String resource = a.getString(R.styleable.ScoreflexView_resource);
    if (null != resource)
        setResource(resource);

    a.recycle();

    // Create the animated spinner

    mProgressBar = (ProgressBar) ((LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.scoreflex_progress_bar, null);
    mProgressBar.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
    addView(mProgressBar);
    LocalBroadcastManager.getInstance(activity).registerReceiver(mLoginReceiver,
            new IntentFilter(Scoreflex.INTENT_USER_LOGED_IN));
    setUserInterfaceState(new InitialState());
}

From source file:cn.edu.zafu.easemob.imagecoverflow.CoverFlowView.java

private void initAttributes(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageCoverFlowView);

    int totalVisibleChildren = a.getInt(R.styleable.ImageCoverFlowView_visibleImage, 3);
    setVisibleImage(totalVisibleChildren);

    reflectHeightFraction = a.getFraction(R.styleable.ImageCoverFlowView_reflectionHeight, 100, 0, 0.0f);
    if (reflectHeightFraction > 100) {
        reflectHeightFraction = 100;// w w  w. j  a v a2s .c o  m
    }
    reflectHeightFraction /= 100;
    reflectGap = a.getDimensionPixelSize(R.styleable.ImageCoverFlowView_reflectionGap, 0);

    mGravity = CoverFlowGravity.values()[a.getInt(R.styleable.ImageCoverFlowView_coverflowGravity,
            CoverFlowGravity.CENTER_VERTICAL.ordinal())];

    mLayoutMode = CoverFlowLayoutMode.values()[a.getInt(R.styleable.ImageCoverFlowView_coverflowLayoutMode,
            CoverFlowLayoutMode.WRAP_CONTENT.ordinal())];

    a.recycle();
}

From source file:com.eutectoid.dosomething.picker.PickerFragment.java

@Override
public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);
    TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.picker_fragment);

    setShowPictures(a.getBoolean(R.styleable.picker_fragment_show_pictures, showPictures));
    String extraFieldsString = a.getString(R.styleable.picker_fragment_extra_fields);
    if (extraFieldsString != null) {
        String[] strings = extraFieldsString.split(",");
        setExtraFields(Arrays.asList(strings));
    }//from ww  w .  j a  va  2  s.  c om

    showTitleBar = a.getBoolean(R.styleable.picker_fragment_show_title_bar, showTitleBar);
    titleText = a.getString(R.styleable.picker_fragment_title_text);
    doneButtonText = a.getString(R.styleable.picker_fragment_done_button_text);
    titleBarBackground = a.getDrawable(R.styleable.picker_fragment_title_bar_background);
    doneButtonBackground = a.getDrawable(R.styleable.picker_fragment_done_button_background);

    a.recycle();
}

From source file:bhav.swipeaction.SwipeAction.java

private void initStyle(Context context, AttributeSet attrs) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwipeAction);
    if (a != null) {
        if (a.hasValue(R.styleable.SwipeAction_src)) {
            icon = a.getDrawable(R.styleable.SwipeAction_src);
        } else {//from   ww w  . j  a  v a 2  s  .co  m
            //default back to available icon
            icon = getResources().getDrawable(android.R.drawable.ic_delete);
        }
        iconPaddingBottom = Math
                .round(a.getDimension(R.styleable.SwipeAction_iconPaddingBottom, DEF_PADDING_BOTTOM));
        iconPaddingTop = Math.round(a.getDimension(R.styleable.SwipeAction_iconPaddingTop, DEF_PADDING_TOP));
        iconPaddingLeft = Math
                .round(a.getDimension(R.styleable.SwipeAction_iconPaddingLeft, DEF_PADDING_START));
        iconPaddingRight = Math
                .round(a.getDimension(R.styleable.SwipeAction_iconPaddingRight, DEF_PADDING_END));
        a.recycle();
    }
}

From source file:co.ceryle.segmentedbutton.SegmentedButton.java

private void getAttributes(AttributeSet attrs) {
    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.SegmentedButton);
    imageTint = typedArray.getColor(R.styleable.SegmentedButton_sb_imageTint, -1);
    hasButtonImageTint = typedArray.hasValue(R.styleable.SegmentedButton_sb_imageTint);
    buttonImageScale = typedArray.getFloat(R.styleable.SegmentedButton_sb_imageScale, 1);

    selectedImageTint = typedArray.getColor(R.styleable.SegmentedButton_sb_selectedImageTint, 0);
    hasSelectedImageTint = typedArray.hasValue(R.styleable.SegmentedButton_sb_selectedImageTint);

    selectedTextColor = typedArray.getColor(R.styleable.SegmentedButton_sb_selectedTextColor, 0);
    hasTextColorOnSelection = typedArray.hasValue(R.styleable.SegmentedButton_sb_selectedTextColor);

    rippleColor = typedArray.getColor(R.styleable.SegmentedButton_sb_rippleColor, 0);
    hasRipple = typedArray.hasValue(R.styleable.SegmentedButton_sb_rippleColor);

    typeface = typedArray.getString(R.styleable.SegmentedButton_sb_typeface);

    try {//w  w  w.  j a  v a 2  s  .c om
        hasWeight = typedArray.hasValue(R.styleable.SegmentedButton_android_layout_weight);
        buttonWeight = typedArray.getFloat(R.styleable.SegmentedButton_android_layout_weight, -1);

        buttonWidth = typedArray.getDimensionPixelSize(R.styleable.SegmentedButton_android_layout_width, 0);
        hasWidth = typedArray.hasValue(R.styleable.SegmentedButton_android_layout_width);

    } catch (Exception ex) {
        Log.d("SegmentedButton", ex.toString());
    }

    typedArray.recycle();
}

From source file:android.hqs.view.pager.indicator.CirclePageIndicator.java

/**
 * ?// w  w  w. j  av  a2 s .  c  o m
 * @param context
 * @param attrs
 * @param defStyle
 */
@SuppressWarnings("deprecation")
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;

    //Load defaults from resources
    final Resources res = getResources();

    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
    mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
    mPaintPageFill.setStyle(Style.FILL);
    mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
    mPaintStroke.setStyle(Style.STROKE);
    mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
    mPaintStroke
            .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintFill.setStyle(Style.FILL);
    mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
    mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
    mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);

    Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
    if (background != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            setBackground(background);
        } else {
            setBackgroundDrawable(background);
        }
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:am.widget.indicatortabstrip.IndicatorTabStrip.java

public IndicatorTabStrip(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setItemClickable(true);/*  www .ja  va  2 s.c o m*/
    setClickSmoothScroll(true);
    final float density = getResources().getDisplayMetrics().density;
    mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setTextAlign(Align.CENTER);
    if (Build.VERSION.SDK_INT > 4) {
        updateTextPaintDensity();
    }
    mTagLocation = new TagLocation(TagLocation.LOCATION_EDGE);
    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    int n = a.getIndexCount();
    int textSize = (int) (DEFAULT_TEXT_SIZE * density);
    ColorStateList textColors = null;
    Drawable divider = null;
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);
        switch (attr) {
        case 0:
            textSize = a.getDimensionPixelSize(attr, textSize);
            break;
        case 1:
            textColors = a.getColorStateList(attr);
            break;
        case 2:
            divider = a.getDrawable(attr);
            break;
        }
    }
    a.recycle();
    float scale = 1;
    Drawable itemBackground = null;
    ColorStateList gradient = null;
    Drawable indicator = null;
    int indicatorWidthMode = INDICATOR_WIDTH_MODE_SET;
    int indicatorPadding = 0;
    int indicatorWidth = INDICATOR_WIDTH_BY_DRAWABLE;
    int indicatorHeight = INDICATOR_HEIGHT_BY_DRAWABLE;
    Drawable interval = null;
    int minItemWidth = (int) (DEFAULT_ITEM_WIDTH * density);
    int minItemHeight = (int) (DEFAULT_ITEM_HEIGHT * density);
    int tagTextSize = (int) (DEFAULT_TAG_TEXT_SIZE * density);
    int tagTextColor = DEFAULT_TAG_TEXT_COLOR;
    Drawable tagBackground = getDefaultTagBackground();
    int tagMinSizeMode = TAG_MIN_SIZE_MODE_HAS_TEXT;
    int tagMinWidth = (int) (DEFAULT_TAG_MIN_SIZE * density);
    int tagMinHeight = (int) (DEFAULT_TAG_MIN_SIZE * density);
    int tagPaddingLeft = 0;
    int tagPaddingTop = 0;
    int tagPaddingRight = 0;
    int tagPaddingBottom = 0;
    int tagMarginLeft = 0;
    int tagMarginTop = 0;
    int tagMarginRight = 0;
    int tagMarginBottom = 0;
    TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.IndicatorTabStrip);
    textSize = custom.getDimensionPixelSize(R.styleable.IndicatorTabStrip_ttsTextSize, textSize);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTextColor))
        textColors = custom.getColorStateList(R.styleable.IndicatorTabStrip_ttsTextColor);
    scale = custom.getFloat(R.styleable.IndicatorTabStrip_ttsTextScale, scale);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsBackground))
        itemBackground = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsBackground);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsGradient))
        gradient = custom.getColorStateList(R.styleable.IndicatorTabStrip_ttsGradient);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsDivider))
        divider = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsDivider);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsIndicator))
        indicator = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsIndicator);
    indicatorWidthMode = custom.getInt(R.styleable.IndicatorTabStrip_ttsIndicatorWidthMode, indicatorWidthMode);
    indicatorPadding = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorPadding,
            indicatorPadding);
    indicatorWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorWidth,
            indicatorWidth);
    indicatorHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorHeight,
            indicatorHeight);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsInterval))
        interval = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsInterval);
    minItemWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsMinItemWidth, minItemWidth);
    minItemHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsMinItemHeight,
            minItemHeight);
    tagTextSize = custom.getDimensionPixelSize(R.styleable.IndicatorTabStrip_ttsTagTextSize, tagTextSize);
    tagTextColor = custom.getColor(R.styleable.IndicatorTabStrip_ttsTagTextColor, tagTextColor);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagBackground))
        tagBackground = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsTagBackground);
    tagMinSizeMode = custom.getInt(R.styleable.IndicatorTabStrip_ttsTagMinSizeMode, tagMinSizeMode);
    tagMinWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMinWidth, tagMinWidth);
    tagMinHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMinHeight, tagMinHeight);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagPadding)) {
        final int padding = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPadding, 0);
        tagPaddingLeft = padding;
        tagPaddingTop = padding;
        tagPaddingRight = padding;
        tagPaddingBottom = padding;
    }
    tagPaddingLeft = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingLeft,
            tagPaddingLeft);
    tagPaddingTop = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingTop,
            tagPaddingTop);
    tagPaddingRight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingRight,
            tagPaddingRight);
    tagPaddingBottom = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingBottom,
            tagPaddingBottom);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagMargin)) {
        final int margin = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMargin, 0);
        tagMarginLeft = margin;
        tagMarginTop = margin;
        tagMarginRight = margin;
        tagMarginBottom = margin;
    }
    tagMarginLeft = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginLeft,
            tagMarginLeft);
    tagMarginTop = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginTop, tagMarginTop);
    tagMarginRight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginRight,
            tagMarginRight);
    tagMarginBottom = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginBottom,
            tagMarginBottom);
    custom.recycle();
    setTextSize(textSize);
    if (textColors != null) {
        setTextColor(textColors);
    } else {
        setTextColor(DEFAULT_TEXT_COLOR);
    }
    setTextScale(scale);
    setItemBackground(itemBackground);
    setGradient(gradient);
    setDivider(divider);
    setIndicator(indicator);
    setIndicatorWidthMode(indicatorWidthMode);
    setIndicatorPadding(indicatorPadding);
    setIndicatorWidth(indicatorWidth);
    setIndicatorHeight(indicatorHeight);
    setInterval(interval);
    setMinItemWidth(minItemWidth);
    setMinItemHeight(minItemHeight);
    setTagTextSize(tagTextSize);
    setTagTextColor(tagTextColor);
    setTagBackground(tagBackground);
    setTagMinSizeMode(tagMinSizeMode);
    setTagMinWidth(tagMinWidth);
    setTagMinHeight(tagMinHeight);
    setTagPadding(tagPaddingLeft, tagPaddingTop, tagPaddingRight, tagPaddingBottom);
    setTagMargin(tagMarginLeft, tagMarginTop, tagMarginRight, tagMarginBottom);
}