Example usage for android.content.res TypedArray getInt

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

Introduction

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

Prototype

public int getInt(@StyleableRes int index, int defValue) 

Source Link

Document

Retrieve the integer value for the attribute at index.

Usage

From source file:com.gosuncn.core.ui.widget.ToolbarExtend.java

public ToolbarExtend(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ToolbarExtend);
    drawableSize = a.getDimensionPixelSize(R.styleable.ToolbarExtend_drawableSize, DEFAULT_SIZE);
    titleGravity = a.getInt(R.styleable.ToolbarExtend_titleGravity, DEFAULT_GRAVITY);

    a.recycle();/*from   w  ww .  ja v  a  2 s . c  o  m*/

    resizeDrawable();
    changeTitleGravity();
}

From source file:com.orangemoo.com.beta.widget.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/*from w w  w.j a v  a 2s  . c o m*/

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    a.recycle();
}

From source file:com.abcs.haiwaigou.yyg.view.ReadMoreTextView.java

public ReadMoreTextView(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ReadMoreTextView);
    this.trimLength = typedArray.getInt(R.styleable.ReadMoreTextView_trimLength, DEFAULT_TRIM_LENGTH);
    int resourceIdTrimCollapsedText = typedArray.getResourceId(R.styleable.ReadMoreTextView_trimCollapsedText,
            R.string.read_more);//from   ww w .ja v a 2 s.  c  om
    int resourceIdTrimExpandedText = typedArray.getResourceId(R.styleable.ReadMoreTextView_trimExpandedText,
            R.string.read_less);
    this.trimCollapsedText = getResources().getString(resourceIdTrimCollapsedText);
    this.trimExpandedText = getResources().getString(resourceIdTrimExpandedText);
    this.trimLines = typedArray.getInt(R.styleable.ReadMoreTextView_trimLines, DEFAULT_TRIM_LINES);
    this.colorClickableText = typedArray.getColor(R.styleable.ReadMoreTextView_colorClickableText,
            ContextCompat.getColor(context, R.color.tljr_statusbarcolor));
    this.showTrimExpandedText = typedArray.getBoolean(R.styleable.ReadMoreTextView_showTrimExpandedText,
            DEFAULT_SHOW_TRIM_EXPANDED_TEXT);
    this.trimMode = typedArray.getInt(R.styleable.ReadMoreTextView_trimMode, TRIM_MODE_LINES);
    typedArray.recycle();
    viewMoreSpan = new ReadMoreClickableSpan();
    onGlobalLayoutLineEndIndex();
    setText();
}

From source file:com.borjabravo.readmoretextview.ReadMoreTextView.java

public ReadMoreTextView(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ReadMoreTextView);
    this.trimLength = typedArray.getInt(R.styleable.ReadMoreTextView_trimLength, DEFAULT_TRIM_LENGTH);
    int resourceIdTrimCollapsedText = typedArray.getResourceId(R.styleable.ReadMoreTextView_trimCollapsedText,
            R.string.read_more);/*from  www.j a v a2s . co m*/
    int resourceIdTrimExpandedText = typedArray.getResourceId(R.styleable.ReadMoreTextView_trimExpandedText,
            R.string.read_less);
    this.trimCollapsedText = getResources().getString(resourceIdTrimCollapsedText);
    this.trimExpandedText = getResources().getString(resourceIdTrimExpandedText);
    this.trimLines = typedArray.getInt(R.styleable.ReadMoreTextView_trimLines, DEFAULT_TRIM_LINES);
    this.colorClickableText = typedArray.getColor(R.styleable.ReadMoreTextView_colorClickableText,
            ContextCompat.getColor(context, R.color.accent));
    this.showTrimExpandedText = typedArray.getBoolean(R.styleable.ReadMoreTextView_showTrimExpandedText,
            DEFAULT_SHOW_TRIM_EXPANDED_TEXT);
    this.trimMode = typedArray.getInt(R.styleable.ReadMoreTextView_trimMode, TRIM_MODE_LINES);
    typedArray.recycle();
    viewMoreSpan = new ReadMoreClickableSpan();
    onGlobalLayoutLineEndIndex();
    setText();
}

From source file:com.cyanogenmod.eleven.widgets.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//from  ww w.ja  v  a 2 s  . c om

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    // enable shadow casting from view bounds
    setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
}

From source file:com.cytmxk.test.animation.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//from   ww  w  . ja  v a  2s.c o m

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();
}

From source file:com.pavelsikun.seekbarpreference.SeekBarPreference.java

private void init(AttributeSet attrs) {
    setLayoutResource(R.layout.seekbar_preference);

    if (attrs == null) {
        mMinValue = DEFAULT_MIN_VALUE;//from w  w  w. jav  a 2  s. com
        mMaxValue = DEFAULT_MAX_VALUE;
        mInterval = DEFAULT_INTERVAL;
        mMeasurementUnit = DEFAULT_MEASUREMENT_UNIT;
        mValueTextSize = DEFAULT_TEXT_SIZE;
    } else {
        TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.SeekBarPreference);
        try {
            mMinValue = ta.getInt(R.styleable.SeekBarPreference_msbp_minValue, DEFAULT_MIN_VALUE);
            mMaxValue = ta.getInt(R.styleable.SeekBarPreference_msbp_maxValue, DEFAULT_MAX_VALUE);
            mInterval = ta.getInt(R.styleable.SeekBarPreference_msbp_interval, DEFAULT_INTERVAL);

            mDefaultValue = attrs.getAttributeIntValue(android.R.attr.defaultValue, DEFAULT_CURRENT_VALUE);

            mValueTextSize = ta.getDimensionPixelSize(R.styleable.SeekBarPreference_msbp_valueTextSize,
                    (int) (getContext().getResources().getDisplayMetrics().density * DEFAULT_TEXT_SIZE));

            if (mDefaultValue < mMinValue) {
                mDefaultValue = (mMaxValue - mMinValue) / 2;
            }
            mMeasurementUnit = ta.getString(R.styleable.SeekBarPreference_msbp_measurementUnit);
            if (mMeasurementUnit == null) {
                mMeasurementUnit = DEFAULT_MEASUREMENT_UNIT;
            }
        } finally {
            ta.recycle();
        }
    }
}

From source file:com.amazonaws.mobile.auth.userpools.SignUpView.java

/**
 * Constructs the SignUp View./*  w w w  .  j a  v a  2  s.c  om*/
 * @param context The activity context.
 * @param attrs The Attribute Set for the view from which the resources can be accessed.
 * @param defStyleAttr The resource identifier for the default style attribute.
 */
public SignUpView(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setOrientation(VERTICAL);

    final int backgroundColor;
    if (isInEditMode()) {
        backgroundColor = Color.DKGRAY;
    } else {
        final TypedArray styledAttributes = context.obtainStyledAttributes(attrs, R.styleable.SignUpView);
        backgroundColor = styledAttributes.getInt(R.styleable.SignUpView_signUpViewBackgroundColor,
                Color.DKGRAY);
        styledAttributes.recycle();
    }

    this.fontFamily = CognitoUserPoolsSignInProvider.getFontFamily();
    this.typeFace = Typeface.create(this.fontFamily, Typeface.NORMAL);
    this.fullScreenBackgroundColor = CognitoUserPoolsSignInProvider.isBackgroundColorFullScreen();
    this.backgroundColor = CognitoUserPoolsSignInProvider.getBackgroundColor();

    if (this.fullScreenBackgroundColor) {
        this.backgroundDrawable = new BackgroundDrawable(this.backgroundColor);
    } else {
        this.splitBackgroundDrawable = new SplitBackgroundDrawable(0, this.backgroundColor);
    }
}

From source file:com.android.messaging.ui.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//from  w  w w.  j a va 2  s.co  m

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    // enable shadow casting from view bounds
    if (OsUtil.isAtLeastL()) {
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setRect(0, 0, view.getWidth(), view.getHeight());
            }
        });
    }
}

From source file:com.cytmxk.test.picture.blurpicture.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/*ww  w  . j a  va  2 s. c  o  m*/

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    // enable shadow casting from view bounds
    setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
}