List of usage examples for android.content Context obtainStyledAttributes
public final TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs)
From source file:cnc.cad.rxjavatestapp.AvatarImageBehavior.java
public AvatarImageBehavior(Context context, AttributeSet attrs) { mContext = context;//from ww w .ja v a 2 s.co m if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AvatarImageBehavior); mCustomFinalHeight = a.getDimension(R.styleable.AvatarImageBehavior_finalHeight, 0); a.recycle(); } }
From source file:com.ameron32.apps.tapnotes._trial.ui.MultiViewPager.java
private void init(Context context, AttributeSet attrs) { setClipChildren(false);//from w w w. j av a 2 s .com TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MultiViewPager); setMaxWidth(ta.getDimensionPixelSize(R.styleable.MultiViewPager_android_maxWidth, -1)); setMaxHeight(ta.getDimensionPixelSize(R.styleable.MultiViewPager_android_maxHeight, -1)); setMatchChildWidth(ta.getResourceId(R.styleable.MultiViewPager_matchChildWidth, 0)); ta.recycle(); }
From source file:com.manning.androidhacks.hack003.view.CascadeLayout.java
public CascadeLayout(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CascadeLayout); try {/*from w w w.ja va2s . c o m*/ mHorizontalSpacing = a.getDimensionPixelSize(R.styleable.CascadeLayout_horizontal_spacing, getResources().getDimensionPixelSize(R.dimen.cascade_horizontal_spacing)); mVerticalSpacing = a.getDimensionPixelSize(R.styleable.CascadeLayout_vertical_spacing, getResources().getDimensionPixelSize(R.dimen.cascade_vertical_spacing)); } finally { a.recycle(); } }
From source file:mil.nga.giat.mage.help.OpensourceItemFragment.java
private void initView(Context context, AttributeSet attrs) { View view = inflate(getContext(), R.layout.fragment_opensource_item, null); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.OpensourceItemFragment); CharSequence name = a.getText(R.styleable.OpensourceItemFragment_name); CharSequence copyright = a.getText(R.styleable.OpensourceItemFragment_copyright); CharSequence license = a.getText(R.styleable.OpensourceItemFragment_license); a.recycle();// w ww . ja va 2s . com TextView nameTextView = (TextView) view.findViewById(R.id.opensource_item_name); if (StringUtils.isBlank(name)) { nameTextView.setVisibility(View.GONE); } else { nameTextView.setText(name); } TextView copyrightTextView = (TextView) view.findViewById(R.id.opensource_item_copyright); if (StringUtils.isBlank(copyright)) { copyrightTextView.setVisibility(View.GONE); } else { copyrightTextView.setText(copyright); } TextView licenseTextView = (TextView) view.findViewById(R.id.opensource_item_license); if (StringUtils.isBlank(license)) { licenseTextView.setVisibility(View.GONE); } else { licenseTextView.setText(license); } } addView(view); }
From source file:android.support.transition.Fade.java
public Fade(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, Styleable.FADE); @Mode// www.j a v a2 s .c o m int fadingMode = TypedArrayUtils.getNamedInt(a, (XmlResourceParser) attrs, "fadingMode", Styleable.Fade.FADING_MODE, getMode()); setMode(fadingMode); a.recycle(); }
From source file:ch.bretscherhochstrasser.android.stickyviewpager.StickyViewPager.java
private void readAttributes(final Context context, final AttributeSet attrs) { final TypedArray styledAttributes = context.obtainStyledAttributes(attrs, R.styleable.StickyViewPager); for (int i = 0; i < styledAttributes.getIndexCount(); ++i) { final int attr = styledAttributes.getIndex(i); if (attr == R.styleable.StickyViewPager_swipeMarginWidth) { swipeMarginWidth = styledAttributes.getDimensionPixelSize(attr, swipeMarginWidth); } else if (attr == R.styleable.StickyViewPager_stickyPositions) { addStickyPositions(styledAttributes.getString(attr)); }/*from www . j av a 2 s .c om*/ } styledAttributes.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 .jav a 2 s . 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.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:android.support.transition.Slide.java
public Slide(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, Styleable.SLIDE); int edge = TypedArrayUtils.getNamedInt(a, (XmlPullParser) attrs, "slideEdge", Styleable.Slide.SLIDE_EDGE, Gravity.BOTTOM);// w ww . java 2 s .c om a.recycle(); //noinspection WrongConstant setSlideEdge(edge); }
From source file:android.support.transition.ArcMotion.java
public ArcMotion(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, Styleable.ARC_MOTION); XmlPullParser parser = (XmlPullParser) attrs; float minimumVerticalAngle = TypedArrayUtils.getNamedFloat(a, parser, "minimumVerticalAngle", Styleable.ArcMotion.MINIMUM_VERTICAL_ANGLE, DEFAULT_MIN_ANGLE_DEGREES); setMinimumVerticalAngle(minimumVerticalAngle); float minimumHorizontalAngle = TypedArrayUtils.getNamedFloat(a, parser, "minimumHorizontalAngle", Styleable.ArcMotion.MINIMUM_HORIZONTAL_ANGLE, DEFAULT_MIN_ANGLE_DEGREES); setMinimumHorizontalAngle(minimumHorizontalAngle); float maximumAngle = TypedArrayUtils.getNamedFloat(a, parser, "maximumAngle", Styleable.ArcMotion.MAXIMUM_ANGLE, DEFAULT_MAX_ANGLE_DEGREES); setMaximumAngle(maximumAngle);/*from w ww . j a v a 2s .c om*/ a.recycle(); }
From source file:am.widget.tabstrip.TabStripView.java
private void initView(Context context, @Nullable AttributeSet attrs) { final TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.TabStripView); mHelper.set(custom.getResourceId(R.styleable.TabStripView_tsvViewPager, NO_ID), custom.getBoolean(R.styleable.TabStripView_tsvAutoFindViewPager, true), custom.getBoolean(R.styleable.TabStripView_tsvClickSmoothScroll, false)); custom.recycle();// ww w . j ava2s .c om }