List of usage examples for android.content Context obtainStyledAttributes
public final TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs)
From source file:am.widget.tabstrip.TabStripViewGroup.java
private void initView(Context context, @Nullable AttributeSet attrs) { final TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.TabStripViewGroup); mHelper.set(custom.getResourceId(R.styleable.TabStripViewGroup_tsgViewPager, NO_ID), custom.getBoolean(R.styleable.TabStripViewGroup_tsgAutoFindViewPager, true), custom.getBoolean(R.styleable.TabStripViewGroup_tsgClickSmoothScroll, false)); custom.recycle();// w ww . j a v a2 s . co m }
From source file:arun.com.chromer.settings.widgets.ColorPreference.java
private void init(Context context, AttributeSet attrs) { setWidgetLayoutResource(R.layout.widget_color_preference); DEFAULT_COLOR = ContextCompat.getColor(getContext(), R.color.colorPrimary); if (attrs != null) { TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ColorPreference); int colorRes = ta.getResourceId(R.styleable.ColorPreference_color, 0); if (colorRes != 0) { color = ContextCompat.getColor(getContext(), colorRes); }/*from w w w . j a v a2s .com*/ ta.recycle(); } }
From source file:ch.heigvd.wordhunt.Interaction.FloatLabelLayout.java
public void init(Context context, AttributeSet attrs) { setOrientation(VERTICAL);//from w w w .j a va2 s . c o m final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout); int leftPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingLeft, dipsToPix(DEFAULT_LABEL_PADDING_LEFT)); int topPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingTop, dipsToPix(DEFAULT_LABEL_PADDING_TOP)); int rightPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingRight, dipsToPix(DEFAULT_LABEL_PADDING_RIGHT)); int bottomPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingBottom, dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM)); mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint); mLabel = new TextView(context); mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding); mLabel.setVisibility(INVISIBLE); mLabel.setText(mHint); ViewCompat.setPivotX(mLabel, 0f); ViewCompat.setPivotY(mLabel, 0f); mLabel.setTextAppearance(context, a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance, android.R.style.TextAppearance_Small)); a.recycle(); addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mInterpolator = AnimationUtils.loadInterpolator(context, Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.interpolator.fast_out_slow_in : android.R.anim.decelerate_interpolator); }
From source file:be.ugent.zeus.hydra.views.ButtonBarLayout.java
public ButtonBarLayout(Context context, AttributeSet attrs) { super(context, attrs); final boolean allowStackingDefault = ConfigurationHelper .getScreenHeightDp(getResources()) >= ALLOW_STACKING_MIN_HEIGHT_DP; final TypedArray ta = context.obtainStyledAttributes(attrs, android.support.v7.appcompat.R.styleable.ButtonBarLayout); mAllowStacking = allowStackingDefault; ta.recycle();/*from w ww .j av a 2s . c o m*/ }
From source file:com.actionbarsherlock.internal.widget.IcsLinearLayout.java
public IcsLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, /*com.android.internal.R.styleable.*/LinearLayout); setDividerDrawable(a.getDrawable(/*com.android.internal.R.styleable.*/LinearLayout_divider)); mShowDividers = a.getInt(/*com.android.internal.R.styleable.*/LinearLayout_showDividers, SHOW_DIVIDER_NONE); mDividerPadding = a.getDimensionPixelSize(/*com.android.internal.R.styleable.*/LinearLayout_dividerPadding, 0);//w w w . j ava 2 s . c o m a.recycle(); }
From source file:ca.uwaterloo.sh6choi.czshopper.ui.FloatLabelLayout.java
public FloatLabelLayout(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(VERTICAL);/*from w w w . j a v a 2s . c om*/ final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout); int leftPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingLeft, dipsToPix(DEFAULT_LABEL_PADDING_LEFT)); int topPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingTop, dipsToPix(DEFAULT_LABEL_PADDING_TOP)); int rightPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingRight, dipsToPix(DEFAULT_LABEL_PADDING_RIGHT)); int bottomPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingBottom, dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM)); mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint); mLabel = new TextView(context); mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding); mLabel.setVisibility(INVISIBLE); mLabel.setText(mHint); ViewCompat.setPivotX(mLabel, 0f); ViewCompat.setPivotY(mLabel, 0f); mLabel.setTextAppearance(context, a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance, android.R.style.TextAppearance_Small)); a.recycle(); addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mInterpolator = AnimationUtils.loadInterpolator(context, Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.interpolator.fast_out_slow_in : android.R.anim.decelerate_interpolator); }
From source file:com.actionbarsherlock.internal.widget.ActionBarContainer.java
public ActionBarContainer(Context context, AttributeSet attrs) { super(context, attrs); setBackgroundDrawable(null);/* w w w. j a v a 2 s .co m*/ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionBar); mBackground = a.getDrawable(R.styleable.SherlockActionBar_background); mStackedBackground = a.getDrawable(R.styleable.SherlockActionBar_backgroundStacked); if (getId() == R.id.abs__split_action_bar) { mIsSplit = true; mSplitBackground = a.getDrawable(R.styleable.SherlockActionBar_backgroundSplit); } a.recycle(); setWillNotDraw(mIsSplit ? mSplitBackground == null : mBackground == null && mStackedBackground == null); }
From source file:cn.ieclipse.af.view.ScrollLayout.java
private void init(Context context, AttributeSet attrs) { if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrollLayout); debug = a.getBoolean(R.styleable.ScrollLayout_debug, false); mSnapVelocity = a.getInt(R.styleable.ScrollLayout_snapVelocity, SNAP_VELOCITY); a.recycle();/*from w ww . j ava 2s . c o m*/ } }
From source file:co.paulburke.android.textviewpager.TextViewPager.java
public TextViewPager(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); mPagerAdapter = new TextViewPagerAdapter(context, mMeasureListener); if (attrs != null) { TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.TextViewPager); int layout = attributes.getResourceId(R.styleable.TextViewPager_textViewLayout, -1); CharSequence text = attributes.getText(R.styleable.TextViewPager_android_text); mPagerAdapter.setTextViewLayout(layout); mPagerAdapter.setText(text);/*from w w w. j av a2 s . c o m*/ attributes.recycle(); } setAdapter(mPagerAdapter); }
From source file:ameircom.keymedia.Activity.transition.FabTransform.java
public FabTransform(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = null;//from w ww. j ava 2s . c o m try { a = context.obtainStyledAttributes(attrs, R.styleable.FabTransform); if (!a.hasValue(R.styleable.FabTransform_fabColor) || !a.hasValue(R.styleable.FabTransform_fabIcon)) { throw new IllegalArgumentException("Must provide both color & icon."); } color = a.getColor(R.styleable.FabTransform_fabColor, Color.TRANSPARENT); icon = a.getResourceId(R.styleable.FabTransform_fabIcon, 0); setPathMotion(new GravityArcMotion()); if (getDuration() < 0) { setDuration(DEFAULT_DURATION); } } finally { a.recycle(); } }